diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
15 files changed, 2871 insertions, 847 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 47a9cdc..6879ebb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -305,6 +305,29 @@ 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 | if (xmlrpc != null) | ||
321 | { | ||
322 | xmlrpc.DeleteChannels(itemID); | ||
323 | xmlrpc.CancelSRDRequests(itemID); | ||
324 | } | ||
325 | |||
326 | // Remove Sensors | ||
327 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | ||
328 | |||
329 | } | ||
330 | |||
308 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) | 331 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) |
309 | { | 332 | { |
310 | List<Object> data = new List<Object>(); | 333 | 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..fce8ff8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,117 @@ | |||
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.Threading; | ||
30 | using System.Reflection; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Runtime.Remoting.Lifetime; | ||
34 | using OpenMetaverse; | ||
35 | using Nini.Config; | ||
36 | using OpenSim; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.CoreModules.World.LightShare; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.ScriptEngine.Shared; | ||
42 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
44 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
45 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | |||
48 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
49 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
50 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
51 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
52 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
53 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
54 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
55 | |||
56 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
57 | { | ||
58 | [Serializable] | ||
59 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
60 | { | ||
61 | internal IScriptEngine m_ScriptEngine; | ||
62 | internal SceneObjectPart m_host; | ||
63 | internal TaskInventoryItem m_item; | ||
64 | internal bool m_CMFunctionsEnabled = false; | ||
65 | |||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) | ||
67 | { | ||
68 | m_ScriptEngine = ScriptEngine; | ||
69 | m_host = host; | ||
70 | m_item = item; | ||
71 | |||
72 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
73 | m_CMFunctionsEnabled = true; | ||
74 | } | ||
75 | |||
76 | public override Object InitializeLifetimeService() | ||
77 | { | ||
78 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
79 | |||
80 | if (lease.CurrentState == LeaseState.Initial) | ||
81 | { | ||
82 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
83 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
84 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
85 | } | ||
86 | return lease; | ||
87 | } | ||
88 | |||
89 | public Scene World | ||
90 | { | ||
91 | get { return m_ScriptEngine.World; } | ||
92 | } | ||
93 | |||
94 | public string cmDetectedCountry(int number) | ||
95 | { | ||
96 | m_host.AddScriptLPS(1); | ||
97 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); | ||
98 | if (detectedParams == null) | ||
99 | return String.Empty; | ||
100 | return detectedParams.Country; | ||
101 | } | ||
102 | |||
103 | public string cmGetAgentCountry(LSL_Key key) | ||
104 | { | ||
105 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
106 | return String.Empty; | ||
107 | |||
108 | UUID uuid; | ||
109 | |||
110 | if (!UUID.TryParse(key, out uuid)) | ||
111 | return String.Empty; | ||
112 | |||
113 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | ||
114 | return account.UserCountry; | ||
115 | } | ||
116 | } | ||
117 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 63f4800..70dea08 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; |
@@ -66,6 +69,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | |||
66 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 69 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
67 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 70 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
68 | using System.Reflection; | 71 | using System.Reflection; |
72 | using Timer = System.Timers.Timer; | ||
69 | 73 | ||
70 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 74 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
71 | { | 75 | { |
@@ -112,17 +116,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
112 | protected int m_notecardLineReadCharsMax = 255; | 116 | protected int m_notecardLineReadCharsMax = 255; |
113 | protected int m_scriptConsoleChannel = 0; | 117 | protected int m_scriptConsoleChannel = 0; |
114 | protected bool m_scriptConsoleChannelEnabled = false; | 118 | protected bool m_scriptConsoleChannelEnabled = false; |
119 | protected bool m_debuggerSafe = false; | ||
115 | protected IUrlModule m_UrlModule = null; | 120 | protected IUrlModule m_UrlModule = null; |
116 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); | 121 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
117 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 122 | new Dictionary<UUID, UserInfoCacheEntry>(); |
123 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | ||
118 | protected ISoundModule m_SoundModule = null; | 124 | protected ISoundModule m_SoundModule = null; |
119 | 125 | ||
126 | // protected Timer m_ShoutSayTimer; | ||
127 | protected int m_SayShoutCount = 0; | ||
128 | DateTime m_lastSayShoutCheck; | ||
129 | |||
130 | private Dictionary<string, string> MovementAnimationsForLSL = | ||
131 | new Dictionary<string, string> { | ||
132 | {"FLY", "Flying"}, | ||
133 | {"FLYSLOW", "FlyingSlow"}, | ||
134 | {"HOVER_UP", "Hovering Up"}, | ||
135 | {"HOVER_DOWN", "Hovering Down"}, | ||
136 | {"HOVER", "Hovering"}, | ||
137 | {"LAND", "Landing"}, | ||
138 | {"FALLDOWN", "Falling Down"}, | ||
139 | {"PREJUMP", "PreJumping"}, | ||
140 | {"JUMP", "Jumping"}, | ||
141 | {"STANDUP", "Standing Up"}, | ||
142 | {"SOFT_LAND", "Soft Landing"}, | ||
143 | {"STAND", "Standing"}, | ||
144 | {"CROUCHWALK", "CrouchWalking"}, | ||
145 | {"RUN", "Running"}, | ||
146 | {"WALK", "Walking"}, | ||
147 | {"CROUCH", "Crouching"}, | ||
148 | {"TURNLEFT", "Turning Left"}, | ||
149 | {"TURNRIGHT", "Turning Right"} | ||
150 | }; | ||
151 | |||
120 | public void Initialize( | 152 | public void Initialize( |
121 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) | 153 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) |
122 | { | 154 | { |
155 | m_lastSayShoutCheck = DateTime.UtcNow; | ||
156 | |||
123 | m_ScriptEngine = scriptEngine; | 157 | m_ScriptEngine = scriptEngine; |
124 | m_host = host; | 158 | m_host = host; |
125 | m_item = item; | 159 | m_item = item; |
160 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
126 | m_coopSleepHandle = coopSleepHandle; | 161 | m_coopSleepHandle = coopSleepHandle; |
127 | 162 | ||
128 | LoadConfig(); | 163 | LoadConfig(); |
@@ -211,6 +246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
211 | get { return m_ScriptEngine.World; } | 246 | get { return m_ScriptEngine.World; } |
212 | } | 247 | } |
213 | 248 | ||
249 | [DebuggerNonUserCode] | ||
214 | public void state(string newState) | 250 | public void state(string newState) |
215 | { | 251 | { |
216 | m_ScriptEngine.SetState(m_item.ItemID, newState); | 252 | m_ScriptEngine.SetState(m_item.ItemID, newState); |
@@ -220,6 +256,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
220 | /// Reset the named script. The script must be present | 256 | /// Reset the named script. The script must be present |
221 | /// in the same prim. | 257 | /// in the same prim. |
222 | /// </summary> | 258 | /// </summary> |
259 | [DebuggerNonUserCode] | ||
223 | public void llResetScript() | 260 | public void llResetScript() |
224 | { | 261 | { |
225 | m_host.AddScriptLPS(1); | 262 | m_host.AddScriptLPS(1); |
@@ -282,6 +319,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
282 | } | 319 | } |
283 | } | 320 | } |
284 | 321 | ||
322 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
323 | { | ||
324 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
325 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
326 | return ret; | ||
327 | |||
328 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
329 | |||
330 | switch (linkType) | ||
331 | { | ||
332 | case ScriptBaseClass.LINK_SET: | ||
333 | return avs; | ||
334 | |||
335 | case ScriptBaseClass.LINK_ROOT: | ||
336 | return ret; | ||
337 | |||
338 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
339 | return avs; | ||
340 | |||
341 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
342 | return avs; | ||
343 | |||
344 | case ScriptBaseClass.LINK_THIS: | ||
345 | return ret; | ||
346 | |||
347 | default: | ||
348 | if (linkType < 0) | ||
349 | return ret; | ||
350 | |||
351 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
352 | |||
353 | if (linkType <= partCount) | ||
354 | { | ||
355 | return ret; | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | linkType = linkType - partCount; | ||
360 | if (linkType > avs.Count) | ||
361 | { | ||
362 | return ret; | ||
363 | } | ||
364 | else | ||
365 | { | ||
366 | ret.Add(avs[linkType-1]); | ||
367 | return ret; | ||
368 | } | ||
369 | } | ||
370 | } | ||
371 | } | ||
372 | |||
285 | public List<SceneObjectPart> GetLinkParts(int linkType) | 373 | public List<SceneObjectPart> GetLinkParts(int linkType) |
286 | { | 374 | { |
287 | return GetLinkParts(m_host, linkType); | 375 | return GetLinkParts(m_host, linkType); |
@@ -290,6 +378,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
290 | public static List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType) | 378 | public static List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType) |
291 | { | 379 | { |
292 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 380 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
381 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
382 | return ret; | ||
293 | ret.Add(part); | 383 | ret.Add(part); |
294 | 384 | ||
295 | switch (linkType) | 385 | switch (linkType) |
@@ -516,31 +606,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
516 | 606 | ||
517 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 607 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
518 | 608 | ||
519 | /// <summary> | 609 | // Utility function for llRot2Euler |
520 | /// Convert an LSL rotation to a Euler vector. | 610 | |
521 | /// </summary> | 611 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
522 | /// <remarks> | 612 | protected double NormalizeAngle(double angle) |
523 | /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf | ||
524 | /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2 | ||
525 | /// </remarks> | ||
526 | /// <param name="r"></param> | ||
527 | /// <returns></returns> | ||
528 | public LSL_Vector llRot2Euler(LSL_Rotation r) | ||
529 | { | 613 | { |
530 | m_host.AddScriptLPS(1); | 614 | if (angle > -Math.PI && angle < Math.PI) |
615 | return angle; | ||
531 | 616 | ||
532 | LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. | 617 | int numPis = (int)(Math.PI / angle); |
533 | double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. | 618 | double remainder = angle - Math.PI * numPis; |
534 | if (m == 0.0) return new LSL_Vector(); | 619 | if (numPis % 2 == 1) |
535 | double x = Math.Atan2(-v.y, v.z); | 620 | return Math.PI - angle; |
536 | double sin = v.x / m; | 621 | return remainder; |
537 | if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. | 622 | } |
538 | double y = Math.Asin(sin); | ||
539 | // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation | ||
540 | 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))); | ||
541 | double z = Math.Atan2(v.y, v.x); | ||
542 | 623 | ||
543 | return new LSL_Vector(x, y, z); | 624 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
625 | { | ||
626 | m_host.AddScriptLPS(1); | ||
627 | LSL_Vector eul = new LSL_Vector(); | ||
628 | |||
629 | double sqw = q1.s*q1.s; | ||
630 | double sqx = q1.x*q1.x; | ||
631 | double sqy = q1.z*q1.z; | ||
632 | double sqz = q1.y*q1.y; | ||
633 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor | ||
634 | double test = q1.x*q1.z + q1.y*q1.s; | ||
635 | if (test > 0.4999*unit) { // singularity at north pole | ||
636 | eul.z = 2 * Math.Atan2(q1.x,q1.s); | ||
637 | eul.y = Math.PI/2; | ||
638 | eul.x = 0; | ||
639 | return eul; | ||
640 | } | ||
641 | if (test < -0.4999*unit) { // singularity at south pole | ||
642 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
643 | eul.y = -Math.PI/2; | ||
644 | eul.x = 0; | ||
645 | return eul; | ||
646 | } | ||
647 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
648 | eul.y = Math.Asin(2*test/unit); | ||
649 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
650 | return eul; | ||
544 | } | 651 | } |
545 | 652 | ||
546 | /* From wiki: | 653 | /* From wiki: |
@@ -593,18 +700,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
593 | m_host.AddScriptLPS(1); | 700 | m_host.AddScriptLPS(1); |
594 | 701 | ||
595 | double x,y,z,s; | 702 | double x,y,z,s; |
596 | 703 | v.x *= 0.5; | |
597 | double c1 = Math.Cos(v.x * 0.5); | 704 | v.y *= 0.5; |
598 | double c2 = Math.Cos(v.y * 0.5); | 705 | v.z *= 0.5; |
599 | double c3 = Math.Cos(v.z * 0.5); | 706 | double c1 = Math.Cos(v.x); |
600 | double s1 = Math.Sin(v.x * 0.5); | 707 | double c2 = Math.Cos(v.y); |
601 | double s2 = Math.Sin(v.y * 0.5); | 708 | double c1c2 = c1 * c2; |
602 | double s3 = Math.Sin(v.z * 0.5); | 709 | double s1 = Math.Sin(v.x); |
603 | 710 | double s2 = Math.Sin(v.y); | |
604 | x = s1 * c2 * c3 + c1 * s2 * s3; | 711 | double s1s2 = s1 * s2; |
605 | y = c1 * s2 * c3 - s1 * c2 * s3; | 712 | double c1s2 = c1 * s2; |
606 | z = s1 * s2 * c3 + c1 * c2 * s3; | 713 | double s1c2 = s1 * c2; |
607 | s = c1 * c2 * c3 - s1 * s2 * s3; | 714 | double c3 = Math.Cos(v.z); |
715 | double s3 = Math.Sin(v.z); | ||
716 | |||
717 | x = s1c2 * c3 + c1s2 * s3; | ||
718 | y = c1s2 * c3 - s1c2 * s3; | ||
719 | z = s1s2 * c3 + c1c2 * s3; | ||
720 | s = c1c2 * c3 - s1s2 * s3; | ||
608 | 721 | ||
609 | return new LSL_Rotation(x, y, z, s); | 722 | return new LSL_Rotation(x, y, z, s); |
610 | } | 723 | } |
@@ -742,77 +855,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
742 | { | 855 | { |
743 | //A and B should both be normalized | 856 | //A and B should both be normalized |
744 | m_host.AddScriptLPS(1); | 857 | m_host.AddScriptLPS(1); |
745 | LSL_Rotation rotBetween; | 858 | /* This method is more accurate than the SL one, and thus causes problems |
746 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 859 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
747 | // continue calculation. | 860 | |
748 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 861 | double dotProduct = LSL_Vector.Dot(a, b); |
862 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
863 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | ||
864 | double angle = Math.Acos(dotProduct / magProduct); | ||
865 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); | ||
866 | double s = Math.Sin(angle / 2); | ||
867 | |||
868 | double x = axis.x * s; | ||
869 | double y = axis.y * s; | ||
870 | double z = axis.z * s; | ||
871 | double w = Math.Cos(angle / 2); | ||
872 | |||
873 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) | ||
874 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
875 | |||
876 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | ||
877 | */ | ||
878 | |||
879 | // This method mimics the 180 errors found in SL | ||
880 | // See www.euclideanspace.com... angleBetween | ||
881 | LSL_Vector vec_a = a; | ||
882 | LSL_Vector vec_b = b; | ||
883 | |||
884 | // Eliminate zero length | ||
885 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
886 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
887 | if (vec_a_mag < 0.00001 || | ||
888 | vec_b_mag < 0.00001) | ||
749 | { | 889 | { |
750 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 890 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
751 | } | 891 | } |
752 | else | 892 | |
893 | // Normalize | ||
894 | vec_a = llVecNorm(vec_a); | ||
895 | vec_b = llVecNorm(vec_b); | ||
896 | |||
897 | // Calculate axis and rotation angle | ||
898 | LSL_Vector axis = vec_a % vec_b; | ||
899 | LSL_Float cos_theta = vec_a * vec_b; | ||
900 | |||
901 | // Check if parallel | ||
902 | if (cos_theta > 0.99999) | ||
753 | { | 903 | { |
754 | a = LSL_Vector.Norm(a); | 904 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
755 | b = LSL_Vector.Norm(b); | 905 | } |
756 | double dotProduct = LSL_Vector.Dot(a, b); | 906 | |
757 | // There are two degenerate cases possible. These are for vectors 180 or | 907 | // Check if anti-parallel |
758 | // 0 degrees apart. These have to be detected and handled individually. | 908 | else if (cos_theta < -0.99999) |
759 | // | 909 | { |
760 | // Check for vectors 180 degrees apart. | 910 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
761 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 911 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
762 | if (dotProduct < -0.9999999f) | 912 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
763 | { | 913 | } |
764 | // First assume X axis is orthogonal to the vectors. | 914 | else // other rotation |
765 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 915 | { |
766 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 916 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
767 | // Check for near zero vector. A very small non-zero number here will create | 917 | axis = llVecNorm(axis); |
768 | // a rotation in an undesired direction. | 918 | double x, y, z, s, t; |
769 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 919 | s = Math.Cos(theta); |
770 | { | 920 | t = Math.Sin(theta); |
771 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 921 | x = axis.x * t; |
772 | } | 922 | y = axis.y * t; |
773 | // If the magnitude of the vector was near zero, then assume the X axis is not | 923 | z = axis.z * t; |
774 | // orthogonal and use the Z axis instead. | 924 | return new LSL_Rotation(x,y,z,s); |
775 | else | ||
776 | { | ||
777 | // Set 180 z rotation. | ||
778 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | ||
779 | } | ||
780 | } | ||
781 | // Check for parallel vectors. | ||
782 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | ||
783 | else if (dotProduct > 0.9999999f) | ||
784 | { | ||
785 | // Set zero rotation. | ||
786 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
787 | } | ||
788 | else | ||
789 | { | ||
790 | // All special checks have been performed so get the axis of rotation. | ||
791 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
792 | // Quarternion s value is the length of the unit vector + dot product. | ||
793 | double qs = 1.0 + dotProduct; | ||
794 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | ||
795 | // Normalize the rotation. | ||
796 | double mag = LSL_Rotation.Mag(rotBetween); | ||
797 | // We shouldn't have to worry about a divide by zero here. The qs value will be | ||
798 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | ||
799 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | ||
800 | // crossProduct vector should also not be zero. | ||
801 | rotBetween.x = rotBetween.x / mag; | ||
802 | rotBetween.y = rotBetween.y / mag; | ||
803 | rotBetween.z = rotBetween.z / mag; | ||
804 | rotBetween.s = rotBetween.s / mag; | ||
805 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | ||
806 | // any longer since zero vectors are checked for at the top. | ||
807 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | ||
808 | { | ||
809 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
810 | } | ||
811 | } | ||
812 | } | 925 | } |
813 | return rotBetween; | ||
814 | } | 926 | } |
815 | 927 | ||
816 | public void llWhisper(int channelID, string text) | 928 | public void llWhisper(int channelID, string text) |
817 | { | 929 | { |
818 | m_host.AddScriptLPS(1); | 930 | m_host.AddScriptLPS(1); |
@@ -828,10 +940,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
828 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); | 940 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); |
829 | } | 941 | } |
830 | 942 | ||
943 | private void CheckSayShoutTime() | ||
944 | { | ||
945 | DateTime now = DateTime.UtcNow; | ||
946 | if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec | ||
947 | { | ||
948 | m_lastSayShoutCheck = now; | ||
949 | m_SayShoutCount = 0; | ||
950 | } | ||
951 | else | ||
952 | m_SayShoutCount++; | ||
953 | } | ||
954 | |||
831 | public void llSay(int channelID, string text) | 955 | public void llSay(int channelID, string text) |
832 | { | 956 | { |
833 | m_host.AddScriptLPS(1); | 957 | m_host.AddScriptLPS(1); |
834 | 958 | ||
959 | if (channelID == 0) | ||
960 | // m_SayShoutCount++; | ||
961 | CheckSayShoutTime(); | ||
962 | |||
963 | if (m_SayShoutCount >= 11) | ||
964 | ScriptSleep(2000); | ||
965 | |||
835 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) | 966 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) |
836 | { | 967 | { |
837 | Console.WriteLine(text); | 968 | Console.WriteLine(text); |
@@ -854,6 +985,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
854 | { | 985 | { |
855 | m_host.AddScriptLPS(1); | 986 | m_host.AddScriptLPS(1); |
856 | 987 | ||
988 | if (channelID == 0) | ||
989 | // m_SayShoutCount++; | ||
990 | CheckSayShoutTime(); | ||
991 | |||
992 | if (m_SayShoutCount >= 11) | ||
993 | ScriptSleep(2000); | ||
994 | |||
857 | if (text.Length > 1023) | 995 | if (text.Length > 1023) |
858 | text = text.Substring(0, 1023); | 996 | text = text.Substring(0, 1023); |
859 | 997 | ||
@@ -885,22 +1023,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
885 | 1023 | ||
886 | public void llRegionSayTo(string target, int channel, string msg) | 1024 | public void llRegionSayTo(string target, int channel, string msg) |
887 | { | 1025 | { |
1026 | string error = String.Empty; | ||
1027 | |||
888 | if (msg.Length > 1023) | 1028 | if (msg.Length > 1023) |
889 | msg = msg.Substring(0, 1023); | 1029 | msg = msg.Substring(0, 1023); |
890 | 1030 | ||
891 | m_host.AddScriptLPS(1); | 1031 | m_host.AddScriptLPS(1); |
892 | 1032 | ||
893 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
894 | { | ||
895 | return; | ||
896 | } | ||
897 | |||
898 | UUID TargetID; | 1033 | UUID TargetID; |
899 | UUID.TryParse(target, out TargetID); | 1034 | UUID.TryParse(target, out TargetID); |
900 | 1035 | ||
901 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 1036 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
902 | if (wComm != null) | 1037 | if (wComm != null) |
903 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); | 1038 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) |
1039 | LSLError(error); | ||
904 | } | 1040 | } |
905 | 1041 | ||
906 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 1042 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -1156,10 +1292,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1156 | return detectedParams.TouchUV; | 1292 | return detectedParams.TouchUV; |
1157 | } | 1293 | } |
1158 | 1294 | ||
1295 | [DebuggerNonUserCode] | ||
1159 | public virtual void llDie() | 1296 | public virtual void llDie() |
1160 | { | 1297 | { |
1161 | m_host.AddScriptLPS(1); | 1298 | m_host.AddScriptLPS(1); |
1162 | throw new SelfDeleteException(); | 1299 | if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); |
1163 | } | 1300 | } |
1164 | 1301 | ||
1165 | public LSL_Float llGround(LSL_Vector offset) | 1302 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1230,6 +1367,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1230 | 1367 | ||
1231 | public void llSetStatus(int status, int value) | 1368 | public void llSetStatus(int status, int value) |
1232 | { | 1369 | { |
1370 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1371 | return; | ||
1233 | m_host.AddScriptLPS(1); | 1372 | m_host.AddScriptLPS(1); |
1234 | 1373 | ||
1235 | int statusrotationaxis = 0; | 1374 | int statusrotationaxis = 0; |
@@ -1253,6 +1392,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1253 | if (!allow) | 1392 | if (!allow) |
1254 | return; | 1393 | return; |
1255 | 1394 | ||
1395 | if (m_host.ParentGroup.RootPart.PhysActor != null && | ||
1396 | m_host.ParentGroup.RootPart.PhysActor.IsPhysical) | ||
1397 | return; | ||
1398 | |||
1256 | m_host.ScriptSetPhysicsStatus(true); | 1399 | m_host.ScriptSetPhysicsStatus(true); |
1257 | } | 1400 | } |
1258 | else | 1401 | else |
@@ -1453,6 +1596,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1453 | { | 1596 | { |
1454 | m_host.AddScriptLPS(1); | 1597 | m_host.AddScriptLPS(1); |
1455 | 1598 | ||
1599 | SetColor(m_host, color, face); | ||
1600 | } | ||
1601 | |||
1602 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1603 | { | ||
1604 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1605 | return; | ||
1606 | |||
1607 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1608 | Color4 texcolor; | ||
1609 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1610 | { | ||
1611 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1612 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1613 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1614 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1615 | tex.FaceTextures[face].RGBA = texcolor; | ||
1616 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1617 | return; | ||
1618 | } | ||
1619 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1620 | { | ||
1621 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1622 | { | ||
1623 | if (tex.FaceTextures[i] != null) | ||
1624 | { | ||
1625 | texcolor = tex.FaceTextures[i].RGBA; | ||
1626 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1627 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1628 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1629 | tex.FaceTextures[i].RGBA = texcolor; | ||
1630 | } | ||
1631 | texcolor = tex.DefaultTexture.RGBA; | ||
1632 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1633 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1634 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1635 | tex.DefaultTexture.RGBA = texcolor; | ||
1636 | } | ||
1637 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1638 | return; | ||
1639 | } | ||
1640 | |||
1456 | if (face == ScriptBaseClass.ALL_SIDES) | 1641 | if (face == ScriptBaseClass.ALL_SIDES) |
1457 | face = SceneObjectPart.ALL_SIDES; | 1642 | face = SceneObjectPart.ALL_SIDES; |
1458 | 1643 | ||
@@ -1461,6 +1646,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1461 | 1646 | ||
1462 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1647 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1463 | { | 1648 | { |
1649 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1650 | return; | ||
1651 | |||
1464 | Primitive.TextureEntry tex = part.Shape.Textures; | 1652 | Primitive.TextureEntry tex = part.Shape.Textures; |
1465 | MappingType textype; | 1653 | MappingType textype; |
1466 | textype = MappingType.Default; | 1654 | textype = MappingType.Default; |
@@ -1491,6 +1679,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1491 | 1679 | ||
1492 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1680 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1493 | { | 1681 | { |
1682 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1683 | return; | ||
1684 | |||
1494 | Primitive.TextureEntry tex = part.Shape.Textures; | 1685 | Primitive.TextureEntry tex = part.Shape.Textures; |
1495 | if (face >= 0 && face < GetNumberOfSides(part)) | 1686 | if (face >= 0 && face < GetNumberOfSides(part)) |
1496 | { | 1687 | { |
@@ -1516,6 +1707,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1516 | 1707 | ||
1517 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1708 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1518 | { | 1709 | { |
1710 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1711 | return; | ||
1519 | 1712 | ||
1520 | Shininess sval = new Shininess(); | 1713 | Shininess sval = new Shininess(); |
1521 | 1714 | ||
@@ -1566,6 +1759,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1566 | 1759 | ||
1567 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1760 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1568 | { | 1761 | { |
1762 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1763 | return; | ||
1764 | |||
1569 | Primitive.TextureEntry tex = part.Shape.Textures; | 1765 | Primitive.TextureEntry tex = part.Shape.Textures; |
1570 | if (face >= 0 && face < GetNumberOfSides(part)) | 1766 | if (face >= 0 && face < GetNumberOfSides(part)) |
1571 | { | 1767 | { |
@@ -1626,13 +1822,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1626 | m_host.AddScriptLPS(1); | 1822 | m_host.AddScriptLPS(1); |
1627 | 1823 | ||
1628 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1824 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1629 | 1825 | if (parts.Count > 0) | |
1630 | foreach (SceneObjectPart part in parts) | 1826 | { |
1631 | SetAlpha(part, alpha, face); | 1827 | try |
1828 | { | ||
1829 | foreach (SceneObjectPart part in parts) | ||
1830 | SetAlpha(part, alpha, face); | ||
1831 | } | ||
1832 | finally | ||
1833 | { | ||
1834 | } | ||
1835 | } | ||
1632 | } | 1836 | } |
1633 | 1837 | ||
1634 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1838 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1635 | { | 1839 | { |
1840 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1841 | return; | ||
1842 | |||
1636 | Primitive.TextureEntry tex = part.Shape.Textures; | 1843 | Primitive.TextureEntry tex = part.Shape.Textures; |
1637 | Color4 texcolor; | 1844 | Color4 texcolor; |
1638 | if (face >= 0 && face < GetNumberOfSides(part)) | 1845 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1685,7 +1892,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1685 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1892 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1686 | float wind, float tension, LSL_Vector Force) | 1893 | float wind, float tension, LSL_Vector Force) |
1687 | { | 1894 | { |
1688 | if (part == null) | 1895 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1689 | return; | 1896 | return; |
1690 | 1897 | ||
1691 | if (flexi) | 1898 | if (flexi) |
@@ -1719,7 +1926,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1719 | /// <param name="falloff"></param> | 1926 | /// <param name="falloff"></param> |
1720 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1927 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1721 | { | 1928 | { |
1722 | if (part == null) | 1929 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1723 | return; | 1930 | return; |
1724 | 1931 | ||
1725 | if (light) | 1932 | if (light) |
@@ -1752,11 +1959,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1752 | Primitive.TextureEntry tex = part.Shape.Textures; | 1959 | Primitive.TextureEntry tex = part.Shape.Textures; |
1753 | Color4 texcolor; | 1960 | Color4 texcolor; |
1754 | LSL_Vector rgb = new LSL_Vector(); | 1961 | LSL_Vector rgb = new LSL_Vector(); |
1962 | int nsides = GetNumberOfSides(part); | ||
1963 | |||
1755 | if (face == ScriptBaseClass.ALL_SIDES) | 1964 | if (face == ScriptBaseClass.ALL_SIDES) |
1756 | { | 1965 | { |
1757 | int i; | 1966 | int i; |
1758 | 1967 | for (i = 0; i < nsides; i++) | |
1759 | for (i = 0 ; i < GetNumberOfSides(part); i++) | ||
1760 | { | 1968 | { |
1761 | texcolor = tex.GetFace((uint)i).RGBA; | 1969 | texcolor = tex.GetFace((uint)i).RGBA; |
1762 | rgb.x += texcolor.R; | 1970 | rgb.x += texcolor.R; |
@@ -1764,14 +1972,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1764 | rgb.z += texcolor.B; | 1972 | rgb.z += texcolor.B; |
1765 | } | 1973 | } |
1766 | 1974 | ||
1767 | rgb.x /= (float)GetNumberOfSides(part); | 1975 | float invnsides = 1.0f / (float)nsides; |
1768 | rgb.y /= (float)GetNumberOfSides(part); | 1976 | |
1769 | rgb.z /= (float)GetNumberOfSides(part); | 1977 | rgb.x *= invnsides; |
1978 | rgb.y *= invnsides; | ||
1979 | rgb.z *= invnsides; | ||
1770 | 1980 | ||
1771 | return rgb; | 1981 | return rgb; |
1772 | } | 1982 | } |
1773 | 1983 | if (face >= 0 && face < nsides) | |
1774 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1775 | { | 1984 | { |
1776 | texcolor = tex.GetFace((uint)face).RGBA; | 1985 | texcolor = tex.GetFace((uint)face).RGBA; |
1777 | rgb.x = texcolor.R; | 1986 | rgb.x = texcolor.R; |
@@ -1798,15 +2007,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1798 | m_host.AddScriptLPS(1); | 2007 | m_host.AddScriptLPS(1); |
1799 | 2008 | ||
1800 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 2009 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1801 | 2010 | if (parts.Count > 0) | |
1802 | foreach (SceneObjectPart part in parts) | 2011 | { |
1803 | SetTexture(part, texture, face); | 2012 | try |
1804 | 2013 | { | |
2014 | foreach (SceneObjectPart part in parts) | ||
2015 | SetTexture(part, texture, face); | ||
2016 | } | ||
2017 | finally | ||
2018 | { | ||
2019 | } | ||
2020 | } | ||
1805 | ScriptSleep(200); | 2021 | ScriptSleep(200); |
1806 | } | 2022 | } |
1807 | 2023 | ||
1808 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 2024 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1809 | { | 2025 | { |
2026 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2027 | return; | ||
2028 | |||
1810 | UUID textureID = new UUID(); | 2029 | UUID textureID = new UUID(); |
1811 | 2030 | ||
1812 | textureID = InventoryKey(texture, (int)AssetType.Texture); | 2031 | textureID = InventoryKey(texture, (int)AssetType.Texture); |
@@ -1851,6 +2070,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1851 | 2070 | ||
1852 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 2071 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1853 | { | 2072 | { |
2073 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2074 | return; | ||
2075 | |||
1854 | Primitive.TextureEntry tex = part.Shape.Textures; | 2076 | Primitive.TextureEntry tex = part.Shape.Textures; |
1855 | if (face >= 0 && face < GetNumberOfSides(part)) | 2077 | if (face >= 0 && face < GetNumberOfSides(part)) |
1856 | { | 2078 | { |
@@ -1887,6 +2109,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1887 | 2109 | ||
1888 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 2110 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1889 | { | 2111 | { |
2112 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2113 | return; | ||
2114 | |||
1890 | Primitive.TextureEntry tex = part.Shape.Textures; | 2115 | Primitive.TextureEntry tex = part.Shape.Textures; |
1891 | if (face >= 0 && face < GetNumberOfSides(part)) | 2116 | if (face >= 0 && face < GetNumberOfSides(part)) |
1892 | { | 2117 | { |
@@ -1923,6 +2148,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1923 | 2148 | ||
1924 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2149 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1925 | { | 2150 | { |
2151 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2152 | return; | ||
2153 | |||
1926 | Primitive.TextureEntry tex = part.Shape.Textures; | 2154 | Primitive.TextureEntry tex = part.Shape.Textures; |
1927 | if (face >= 0 && face < GetNumberOfSides(part)) | 2155 | if (face >= 0 && face < GetNumberOfSides(part)) |
1928 | { | 2156 | { |
@@ -2064,7 +2292,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2064 | return end; | 2292 | return end; |
2065 | } | 2293 | } |
2066 | 2294 | ||
2067 | protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos) | 2295 | protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos, bool adjust) |
2068 | { | 2296 | { |
2069 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 2297 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2070 | return fromPos; | 2298 | return fromPos; |
@@ -2080,9 +2308,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2080 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | 2308 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) |
2081 | targetPos.z = ground; | 2309 | targetPos.z = ground; |
2082 | } | 2310 | } |
2083 | LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); | 2311 | if (adjust) |
2312 | return SetPosAdjust(fromPos, targetPos); | ||
2084 | 2313 | ||
2085 | return real_vec; | 2314 | return targetPos; |
2086 | } | 2315 | } |
2087 | 2316 | ||
2088 | /// <summary> | 2317 | /// <summary> |
@@ -2093,27 +2322,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2093 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> | 2322 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> |
2094 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) | 2323 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) |
2095 | { | 2324 | { |
2096 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2325 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2326 | return; | ||
2327 | |||
2097 | LSL_Vector currentPos = GetPartLocalPos(part); | 2328 | LSL_Vector currentPos = GetPartLocalPos(part); |
2329 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); | ||
2098 | 2330 | ||
2099 | float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); | ||
2100 | bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); | ||
2101 | 2331 | ||
2102 | if (part.ParentGroup.RootPart == part) | 2332 | if (part.ParentGroup.RootPart == part) |
2103 | { | 2333 | { |
2104 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | ||
2105 | targetPos.z = ground; | ||
2106 | SceneObjectGroup parent = part.ParentGroup; | 2334 | SceneObjectGroup parent = part.ParentGroup; |
2107 | parent.UpdateGroupPosition(!adjust ? targetPos : | 2335 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) |
2108 | SetPosAdjust(currentPos, targetPos)); | 2336 | return; |
2337 | Util.FireAndForget(delegate(object x) { | ||
2338 | parent.UpdateGroupPosition((Vector3)toPos); | ||
2339 | }); | ||
2109 | } | 2340 | } |
2110 | else | 2341 | else |
2111 | { | 2342 | { |
2112 | part.OffsetPosition = !adjust ? targetPos : | 2343 | part.OffsetPosition = (Vector3)toPos; |
2113 | SetPosAdjust(currentPos, targetPos); | 2344 | // SceneObjectGroup parent = part.ParentGroup; |
2114 | SceneObjectGroup parent = part.ParentGroup; | 2345 | // parent.HasGroupChanged = true; |
2115 | parent.HasGroupChanged = true; | 2346 | // parent.ScheduleGroupForTerseUpdate(); |
2116 | parent.ScheduleGroupForTerseUpdate(); | 2347 | part.ScheduleTerseUpdate(); |
2117 | } | 2348 | } |
2118 | } | 2349 | } |
2119 | 2350 | ||
@@ -2142,13 +2373,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2142 | else | 2373 | else |
2143 | { | 2374 | { |
2144 | if (part.ParentGroup.IsAttachment) | 2375 | if (part.ParentGroup.IsAttachment) |
2145 | { | ||
2146 | pos = part.AttachedPos; | 2376 | pos = part.AttachedPos; |
2147 | } | ||
2148 | else | 2377 | else |
2149 | { | ||
2150 | pos = part.AbsolutePosition; | 2378 | pos = part.AbsolutePosition; |
2151 | } | ||
2152 | } | 2379 | } |
2153 | 2380 | ||
2154 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); | 2381 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); |
@@ -2160,8 +2387,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2160 | { | 2387 | { |
2161 | m_host.AddScriptLPS(1); | 2388 | m_host.AddScriptLPS(1); |
2162 | 2389 | ||
2390 | |||
2391 | // Teravus: if (m_host.ParentID == 0) is bug code because the ParentID for the Avatar will cause this to be nonzero for root prim attachments | ||
2392 | // which is then treated like a child prim rotation and it's offset gets cumulatively multiplied against. | ||
2393 | // to fix the scripted rotations we also have to check to see if the root part localid is the same as the host's localid. | ||
2394 | // RootPart != null should shortcircuit | ||
2395 | |||
2163 | // try to let this work as in SL... | 2396 | // try to let this work as in SL... |
2164 | if (m_host.ParentID == 0) | 2397 | if (m_host.ParentID == 0 || (m_host.ParentGroup != null && m_host == m_host.ParentGroup.RootPart)) |
2165 | { | 2398 | { |
2166 | // special case: If we are root, rotate complete SOG to new rotation | 2399 | // special case: If we are root, rotate complete SOG to new rotation |
2167 | SetRot(m_host, rot); | 2400 | SetRot(m_host, rot); |
@@ -2188,25 +2421,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2188 | 2421 | ||
2189 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2422 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2190 | { | 2423 | { |
2191 | part.UpdateRotation(rot); | 2424 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2192 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2425 | return; |
2193 | 2426 | ||
2194 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type | 2427 | bool isroot = (part == part.ParentGroup.RootPart); |
2195 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | 2428 | bool isphys; |
2196 | 2429 | ||
2197 | // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line | ||
2198 | // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt | ||
2199 | // It's perfectly okay when the object is not an active physical body though. | ||
2200 | // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against | ||
2201 | // but only if the object is not physial and active. This is important for rotating doors. | ||
2202 | // without the absoluteposition = absoluteposition happening, the doors do not move in the physics | ||
2203 | // scene | ||
2204 | PhysicsActor pa = part.PhysActor; | 2430 | PhysicsActor pa = part.PhysActor; |
2205 | 2431 | ||
2206 | if (pa != null && !pa.IsPhysical) | 2432 | // keep using physactor ideia of isphysical |
2433 | // it should be SOP ideia of that | ||
2434 | // not much of a issue with ubitODE | ||
2435 | if (pa != null && pa.IsPhysical) | ||
2436 | isphys = true; | ||
2437 | else | ||
2438 | isphys = false; | ||
2439 | |||
2440 | // SL doesn't let scripts rotate root of physical linksets | ||
2441 | if (isroot && isphys) | ||
2442 | return; | ||
2443 | |||
2444 | part.UpdateRotation(rot); | ||
2445 | |||
2446 | // Update rotation does not move the object in the physics engine if it's a non physical linkset | ||
2447 | // so do a nasty update of parts positions if is a root part rotation | ||
2448 | if (isroot && pa != null) // with if above implies non physical root part | ||
2207 | { | 2449 | { |
2208 | part.ParentGroup.ResetChildPrimPhysicsPositions(); | 2450 | part.ParentGroup.ResetChildPrimPhysicsPositions(); |
2209 | } | 2451 | } |
2452 | else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part | ||
2453 | { | ||
2454 | List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars(); | ||
2455 | if (sittingavas.Count > 0) | ||
2456 | { | ||
2457 | foreach (ScenePresence av in sittingavas) | ||
2458 | { | ||
2459 | if (isroot || part.LocalId == av.ParentID) | ||
2460 | av.SendTerseUpdateToAllClients(); | ||
2461 | } | ||
2462 | } | ||
2463 | } | ||
2210 | } | 2464 | } |
2211 | 2465 | ||
2212 | /// <summary> | 2466 | /// <summary> |
@@ -2223,6 +2477,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2223 | 2477 | ||
2224 | m_host.AddScriptLPS(1); | 2478 | m_host.AddScriptLPS(1); |
2225 | Quaternion q = m_host.GetWorldRotation(); | 2479 | Quaternion q = m_host.GetWorldRotation(); |
2480 | |||
2481 | if (m_host.ParentGroup != null && m_host.ParentGroup.AttachmentPoint != 0) | ||
2482 | { | ||
2483 | ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | ||
2484 | if (avatar != null) | ||
2485 | { | ||
2486 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | ||
2487 | q = avatar.CameraRotation * q; // Mouselook | ||
2488 | else | ||
2489 | q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate | ||
2490 | } | ||
2491 | } | ||
2492 | |||
2226 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 2493 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
2227 | } | 2494 | } |
2228 | 2495 | ||
@@ -2248,14 +2515,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2248 | q = part.ParentGroup.GroupRotation; // just the group rotation | 2515 | q = part.ParentGroup.GroupRotation; // just the group rotation |
2249 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 2516 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
2250 | } | 2517 | } |
2518 | |||
2251 | q = part.GetWorldRotation(); | 2519 | q = part.GetWorldRotation(); |
2520 | if (part.ParentGroup.AttachmentPoint != 0) | ||
2521 | { | ||
2522 | ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); | ||
2523 | if (avatar != null) | ||
2524 | { | ||
2525 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | ||
2526 | q = avatar.CameraRotation * q; // Mouselook | ||
2527 | else | ||
2528 | q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate | ||
2529 | } | ||
2530 | } | ||
2531 | |||
2252 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 2532 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
2253 | } | 2533 | } |
2254 | 2534 | ||
2255 | public LSL_Rotation llGetLocalRot() | 2535 | public LSL_Rotation llGetLocalRot() |
2256 | { | 2536 | { |
2537 | return GetPartLocalRot(m_host); | ||
2538 | } | ||
2539 | |||
2540 | private LSL_Rotation GetPartLocalRot(SceneObjectPart part) | ||
2541 | { | ||
2257 | m_host.AddScriptLPS(1); | 2542 | m_host.AddScriptLPS(1); |
2258 | return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); | 2543 | Quaternion rot = part.RotationOffset; |
2544 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2259 | } | 2545 | } |
2260 | 2546 | ||
2261 | public void llSetForce(LSL_Vector force, int local) | 2547 | public void llSetForce(LSL_Vector force, int local) |
@@ -2335,16 +2621,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2335 | m_host.ApplyImpulse(v, local != 0); | 2621 | m_host.ApplyImpulse(v, local != 0); |
2336 | } | 2622 | } |
2337 | 2623 | ||
2624 | |||
2338 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 2625 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
2339 | { | 2626 | { |
2340 | m_host.AddScriptLPS(1); | 2627 | m_host.AddScriptLPS(1); |
2341 | m_host.ApplyAngularImpulse(force, local != 0); | 2628 | m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0); |
2342 | } | 2629 | } |
2343 | 2630 | ||
2344 | public void llSetTorque(LSL_Vector torque, int local) | 2631 | public void llSetTorque(LSL_Vector torque, int local) |
2345 | { | 2632 | { |
2346 | m_host.AddScriptLPS(1); | 2633 | m_host.AddScriptLPS(1); |
2347 | m_host.SetAngularImpulse(torque, local != 0); | 2634 | m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0); |
2348 | } | 2635 | } |
2349 | 2636 | ||
2350 | public LSL_Vector llGetTorque() | 2637 | public LSL_Vector llGetTorque() |
@@ -2361,20 +2648,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2361 | llSetTorque(torque, local); | 2648 | llSetTorque(torque, local); |
2362 | } | 2649 | } |
2363 | 2650 | ||
2651 | public void llSetVelocity(LSL_Vector vel, int local) | ||
2652 | { | ||
2653 | m_host.AddScriptLPS(1); | ||
2654 | m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); | ||
2655 | } | ||
2656 | |||
2364 | public LSL_Vector llGetVel() | 2657 | public LSL_Vector llGetVel() |
2365 | { | 2658 | { |
2366 | m_host.AddScriptLPS(1); | 2659 | m_host.AddScriptLPS(1); |
2367 | 2660 | ||
2368 | Vector3 vel; | 2661 | Vector3 vel = Vector3.Zero; |
2369 | 2662 | ||
2370 | if (m_host.ParentGroup.IsAttachment) | 2663 | if (m_host.ParentGroup.IsAttachment) |
2371 | { | 2664 | { |
2372 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | 2665 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); |
2373 | vel = avatar.Velocity; | 2666 | if (avatar != null) |
2667 | vel = avatar.Velocity; | ||
2374 | } | 2668 | } |
2375 | else | 2669 | else |
2376 | { | 2670 | { |
2377 | vel = m_host.Velocity; | 2671 | vel = m_host.ParentGroup.RootPart.Velocity; |
2378 | } | 2672 | } |
2379 | 2673 | ||
2380 | return new LSL_Vector(vel.X, vel.Y, vel.Z); | 2674 | return new LSL_Vector(vel.X, vel.Y, vel.Z); |
@@ -2386,10 +2680,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2386 | return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); | 2680 | return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); |
2387 | } | 2681 | } |
2388 | 2682 | ||
2683 | public void llSetAngularVelocity(LSL_Vector avel, int local) | ||
2684 | { | ||
2685 | m_host.AddScriptLPS(1); | ||
2686 | m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); | ||
2687 | } | ||
2688 | |||
2389 | public LSL_Vector llGetOmega() | 2689 | public LSL_Vector llGetOmega() |
2390 | { | 2690 | { |
2391 | m_host.AddScriptLPS(1); | 2691 | m_host.AddScriptLPS(1); |
2392 | return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); | 2692 | Vector3 avel = m_host.AngularVelocity; |
2693 | return new LSL_Vector(avel.X, avel.Y, avel.Z); | ||
2393 | } | 2694 | } |
2394 | 2695 | ||
2395 | public LSL_Float llGetTimeOfDay() | 2696 | public LSL_Float llGetTimeOfDay() |
@@ -2780,7 +3081,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2780 | } | 3081 | } |
2781 | 3082 | ||
2782 | money.ObjectGiveMoney( | 3083 | money.ObjectGiveMoney( |
2783 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | 3084 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero); |
2784 | }); | 3085 | }); |
2785 | } | 3086 | } |
2786 | 3087 | ||
@@ -2860,13 +3161,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2860 | new_group.RootPart.UUID.ToString()) }, | 3161 | new_group.RootPart.UUID.ToString()) }, |
2861 | new DetectParams[0])); | 3162 | new DetectParams[0])); |
2862 | 3163 | ||
2863 | float groupmass = new_group.GetMass(); | 3164 | // do recoil |
3165 | SceneObjectGroup hostgrp = m_host.ParentGroup; | ||
3166 | if (hostgrp == null) | ||
3167 | return; | ||
3168 | |||
3169 | if (hostgrp.IsAttachment) // don't recoil avatars | ||
3170 | return; | ||
2864 | 3171 | ||
2865 | PhysicsActor pa = new_group.RootPart.PhysActor; | 3172 | PhysicsActor pa = new_group.RootPart.PhysActor; |
2866 | 3173 | ||
2867 | //Recoil. | 3174 | //Recoil. |
2868 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) | 3175 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) |
2869 | { | 3176 | { |
3177 | float groupmass = new_group.GetMass(); | ||
2870 | Vector3 recoil = -vel * groupmass * m_recoilScaleFactor; | 3178 | Vector3 recoil = -vel * groupmass * m_recoilScaleFactor; |
2871 | if (recoil != Vector3.Zero) | 3179 | if (recoil != Vector3.Zero) |
2872 | { | 3180 | { |
@@ -2874,6 +3182,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2874 | } | 3182 | } |
2875 | } | 3183 | } |
2876 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | 3184 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) |
3185 | return; | ||
3186 | |||
2877 | }); | 3187 | }); |
2878 | 3188 | ||
2879 | //ScriptSleep((int)((groupmass * velmag) / 10)); | 3189 | //ScriptSleep((int)((groupmass * velmag) / 10)); |
@@ -2888,35 +3198,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2888 | public void llLookAt(LSL_Vector target, double strength, double damping) | 3198 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2889 | { | 3199 | { |
2890 | m_host.AddScriptLPS(1); | 3200 | m_host.AddScriptLPS(1); |
2891 | // Determine where we are looking from | ||
2892 | LSL_Vector from = llGetPos(); | ||
2893 | 3201 | ||
2894 | // Work out the normalised vector from the source to the target | 3202 | // Get the normalized vector to the target |
2895 | LSL_Vector delta = llVecNorm(target - from); | 3203 | LSL_Vector d1 = llVecNorm(target - llGetPos()); |
2896 | LSL_Vector angle = new LSL_Vector(0,0,0); | ||
2897 | 3204 | ||
2898 | // Calculate the yaw | 3205 | // Get the bearing (yaw) |
2899 | // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system | 3206 | LSL_Vector a1 = new LSL_Vector(0,0,0); |
2900 | angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO; | 3207 | a1.z = llAtan2(d1.y, d1.x); |
2901 | 3208 | ||
2902 | // Calculate pitch | 3209 | // Get the elevation (pitch) |
2903 | angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z))); | 3210 | LSL_Vector a2 = new LSL_Vector(0,0,0); |
3211 | a2.y= -llAtan2(d1.z, llSqrt((d1.x * d1.x) + (d1.y * d1.y))); | ||
2904 | 3212 | ||
2905 | // we need to convert from a vector describing | 3213 | LSL_Rotation r1 = llEuler2Rot(a1); |
2906 | // the angles of rotation in radians into rotation value | 3214 | LSL_Rotation r2 = llEuler2Rot(a2); |
2907 | LSL_Rotation rot = llEuler2Rot(angle); | 3215 | LSL_Rotation r3 = new LSL_Rotation(0.000000, 0.707107, 0.000000, 0.707107); |
2908 | |||
2909 | // Per discussion with Melanie, for non-physical objects llLookAt appears to simply | ||
2910 | // set the rotation of the object, copy that behavior | ||
2911 | PhysicsActor pa = m_host.PhysActor; | ||
2912 | 3216 | ||
2913 | if (strength == 0 || pa == null || !pa.IsPhysical) | 3217 | if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) |
2914 | { | 3218 | { |
2915 | llSetRot(rot); | 3219 | // Do nothing if either value is 0 (this has been checked in SL) |
3220 | if (strength <= 0.0 || damping <= 0.0) | ||
3221 | return; | ||
3222 | |||
3223 | llSetRot(r3 * r2 * r1); | ||
2916 | } | 3224 | } |
2917 | else | 3225 | else |
2918 | { | 3226 | { |
2919 | m_host.StartLookAt(rot, (float)strength, (float)damping); | 3227 | if (strength == 0) |
3228 | { | ||
3229 | llSetRot(r3 * r2 * r1); | ||
3230 | return; | ||
3231 | } | ||
3232 | |||
3233 | m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping); | ||
2920 | } | 3234 | } |
2921 | } | 3235 | } |
2922 | 3236 | ||
@@ -2963,17 +3277,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2963 | } | 3277 | } |
2964 | else | 3278 | else |
2965 | { | 3279 | { |
2966 | if (m_host.IsRoot) | 3280 | // new SL always returns object mass |
2967 | { | 3281 | // if (m_host.IsRoot) |
3282 | // { | ||
2968 | return m_host.ParentGroup.GetMass(); | 3283 | return m_host.ParentGroup.GetMass(); |
2969 | } | 3284 | // } |
2970 | else | 3285 | // else |
2971 | { | 3286 | // { |
2972 | return m_host.GetMass(); | 3287 | // return m_host.GetMass(); |
2973 | } | 3288 | // } |
2974 | } | 3289 | } |
2975 | } | 3290 | } |
2976 | 3291 | ||
3292 | |||
3293 | public LSL_Float llGetMassMKS() | ||
3294 | { | ||
3295 | return 100f * llGetMass(); | ||
3296 | } | ||
3297 | |||
2977 | public void llCollisionFilter(string name, string id, int accept) | 3298 | public void llCollisionFilter(string name, string id, int accept) |
2978 | { | 3299 | { |
2979 | m_host.AddScriptLPS(1); | 3300 | m_host.AddScriptLPS(1); |
@@ -3021,8 +3342,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3021 | { | 3342 | { |
3022 | // Unregister controls from Presence | 3343 | // Unregister controls from Presence |
3023 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); | 3344 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); |
3024 | // Remove Take Control permission. | ||
3025 | m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | ||
3026 | } | 3345 | } |
3027 | } | 3346 | } |
3028 | } | 3347 | } |
@@ -3050,7 +3369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3050 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3369 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3051 | 3370 | ||
3052 | if (attachmentsModule != null) | 3371 | if (attachmentsModule != null) |
3053 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, false); | 3372 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false); |
3054 | else | 3373 | else |
3055 | return false; | 3374 | return false; |
3056 | } | 3375 | } |
@@ -3080,9 +3399,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3080 | { | 3399 | { |
3081 | m_host.AddScriptLPS(1); | 3400 | m_host.AddScriptLPS(1); |
3082 | 3401 | ||
3083 | // if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
3084 | // return; | ||
3085 | |||
3086 | if (m_item.PermsGranter != m_host.OwnerID) | 3402 | if (m_item.PermsGranter != m_host.OwnerID) |
3087 | return; | 3403 | return; |
3088 | 3404 | ||
@@ -3125,6 +3441,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3125 | 3441 | ||
3126 | public void llInstantMessage(string user, string message) | 3442 | public void llInstantMessage(string user, string message) |
3127 | { | 3443 | { |
3444 | UUID result; | ||
3445 | if (!UUID.TryParse(user, out result) || result == UUID.Zero) | ||
3446 | { | ||
3447 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3448 | ScriptSleep(2000); | ||
3449 | return; | ||
3450 | } | ||
3451 | |||
3452 | |||
3128 | m_host.AddScriptLPS(1); | 3453 | m_host.AddScriptLPS(1); |
3129 | 3454 | ||
3130 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3455 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3139,14 +3464,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3139 | UUID friendTransactionID = UUID.Random(); | 3464 | UUID friendTransactionID = UUID.Random(); |
3140 | 3465 | ||
3141 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3466 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3142 | 3467 | ||
3143 | GridInstantMessage msg = new GridInstantMessage(); | 3468 | GridInstantMessage msg = new GridInstantMessage(); |
3144 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3469 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3145 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3470 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3146 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3471 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3147 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3472 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3148 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3473 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3149 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3474 | // DateTime dt = DateTime.UtcNow; |
3475 | // | ||
3476 | // // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3477 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3478 | // | ||
3479 | // try | ||
3480 | // { | ||
3481 | // // Convert that to the PST timezone | ||
3482 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3483 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3484 | // } | ||
3485 | // catch | ||
3486 | // { | ||
3487 | // // No logging here, as it could be VERY spammy | ||
3488 | // } | ||
3489 | // | ||
3490 | // // And make it look local again to fool the unix time util | ||
3491 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3492 | |||
3493 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
3494 | |||
3150 | //if (client != null) | 3495 | //if (client != null) |
3151 | //{ | 3496 | //{ |
3152 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3497 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3160,12 +3505,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3160 | msg.message = message.Substring(0, 1024); | 3505 | msg.message = message.Substring(0, 1024); |
3161 | else | 3506 | else |
3162 | msg.message = message; | 3507 | msg.message = message; |
3163 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3508 | msg.dialog = (byte)19; // MessageFromObject |
3164 | msg.fromGroup = false;// fromGroup; | 3509 | msg.fromGroup = false;// fromGroup; |
3165 | msg.offline = (byte)0; //offline; | 3510 | msg.offline = (byte)0; //offline; |
3166 | msg.ParentEstateID = 0; //ParentEstateID; | 3511 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3167 | msg.Position = new Vector3(m_host.AbsolutePosition); | 3512 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3168 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3513 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3169 | msg.binaryBucket | 3514 | msg.binaryBucket |
3170 | = Util.StringToBytes256( | 3515 | = Util.StringToBytes256( |
3171 | "{0}/{1}/{2}/{3}", | 3516 | "{0}/{1}/{2}/{3}", |
@@ -3193,7 +3538,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3193 | } | 3538 | } |
3194 | 3539 | ||
3195 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3540 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3196 | llSleep(EMAIL_PAUSE_TIME); | 3541 | ScriptSleep(EMAIL_PAUSE_TIME * 1000); |
3197 | } | 3542 | } |
3198 | 3543 | ||
3199 | public void llGetNextEmail(string address, string subject) | 3544 | public void llGetNextEmail(string address, string subject) |
@@ -3439,7 +3784,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3439 | implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | | 3784 | implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | |
3440 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | 3785 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | |
3441 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | | 3786 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | |
3787 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | | ||
3442 | ScriptBaseClass.PERMISSION_ATTACH; | 3788 | ScriptBaseClass.PERMISSION_ATTACH; |
3789 | |||
3443 | } | 3790 | } |
3444 | else | 3791 | else |
3445 | { | 3792 | { |
@@ -3456,15 +3803,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3456 | if (World.GetExtraSetting("auto_grant_attach_perms") == "true") | 3803 | if (World.GetExtraSetting("auto_grant_attach_perms") == "true") |
3457 | implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; | 3804 | implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; |
3458 | } | 3805 | } |
3806 | if (World.GetExtraSetting("auto_grant_all_perms") == "true") | ||
3807 | { | ||
3808 | implicitPerms = perm; | ||
3809 | } | ||
3459 | } | 3810 | } |
3460 | 3811 | ||
3461 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3812 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3462 | { | 3813 | { |
3463 | lock (m_host.TaskInventory) | 3814 | m_host.TaskInventory.LockItemsForWrite(true); |
3464 | { | 3815 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3465 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3816 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3466 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | 3817 | m_host.TaskInventory.LockItemsForWrite(false); |
3467 | } | ||
3468 | 3818 | ||
3469 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 3819 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3470 | "run_time_permissions", new Object[] { | 3820 | "run_time_permissions", new Object[] { |
@@ -3507,11 +3857,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3507 | 3857 | ||
3508 | if (!m_waitingForScriptAnswer) | 3858 | if (!m_waitingForScriptAnswer) |
3509 | { | 3859 | { |
3510 | lock (m_host.TaskInventory) | 3860 | m_host.TaskInventory.LockItemsForWrite(true); |
3511 | { | 3861 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3512 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3862 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; |
3513 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; | 3863 | m_host.TaskInventory.LockItemsForWrite(false); |
3514 | } | ||
3515 | 3864 | ||
3516 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3865 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3517 | m_waitingForScriptAnswer=true; | 3866 | m_waitingForScriptAnswer=true; |
@@ -3540,14 +3889,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3540 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3889 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3541 | llReleaseControls(); | 3890 | llReleaseControls(); |
3542 | 3891 | ||
3543 | lock (m_host.TaskInventory) | 3892 | m_host.TaskInventory.LockItemsForWrite(true); |
3544 | { | 3893 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; |
3545 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; | 3894 | m_host.TaskInventory.LockItemsForWrite(false); |
3546 | } | 3895 | |
3547 | 3896 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | |
3548 | m_ScriptEngine.PostScriptEvent( | 3897 | "run_time_permissions", new Object[] { |
3549 | m_item.ItemID, | 3898 | new LSL_Integer(answer) }, |
3550 | new EventParams("run_time_permissions", new Object[] { new LSL_Integer(answer) }, new DetectParams[0])); | 3899 | new DetectParams[0])); |
3551 | } | 3900 | } |
3552 | 3901 | ||
3553 | public LSL_String llGetPermissionsKey() | 3902 | public LSL_String llGetPermissionsKey() |
@@ -3586,14 +3935,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3586 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3935 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3587 | { | 3936 | { |
3588 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3937 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3589 | 3938 | if (parts.Count > 0) | |
3590 | foreach (SceneObjectPart part in parts) | 3939 | { |
3591 | part.SetFaceColorAlpha(face, color, null); | 3940 | try |
3941 | { | ||
3942 | foreach (SceneObjectPart part in parts) | ||
3943 | part.SetFaceColorAlpha(face, color, null); | ||
3944 | } | ||
3945 | finally | ||
3946 | { | ||
3947 | } | ||
3948 | } | ||
3592 | } | 3949 | } |
3593 | 3950 | ||
3594 | public void llCreateLink(string target, int parent) | 3951 | public void llCreateLink(string target, int parent) |
3595 | { | 3952 | { |
3596 | m_host.AddScriptLPS(1); | 3953 | m_host.AddScriptLPS(1); |
3954 | |||
3597 | UUID targetID; | 3955 | UUID targetID; |
3598 | 3956 | ||
3599 | if (!UUID.TryParse(target, out targetID)) | 3957 | if (!UUID.TryParse(target, out targetID)) |
@@ -3699,10 +4057,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3699 | // Restructuring Multiple Prims. | 4057 | // Restructuring Multiple Prims. |
3700 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 4058 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
3701 | parts.Remove(parentPrim.RootPart); | 4059 | parts.Remove(parentPrim.RootPart); |
3702 | foreach (SceneObjectPart part in parts) | 4060 | if (parts.Count > 0) |
3703 | { | 4061 | { |
3704 | parentPrim.DelinkFromGroup(part.LocalId, true); | 4062 | try |
4063 | { | ||
4064 | foreach (SceneObjectPart part in parts) | ||
4065 | { | ||
4066 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
4067 | } | ||
4068 | } | ||
4069 | finally | ||
4070 | { | ||
4071 | } | ||
3705 | } | 4072 | } |
4073 | |||
3706 | parentPrim.HasGroupChanged = true; | 4074 | parentPrim.HasGroupChanged = true; |
3707 | parentPrim.ScheduleGroupForFullUpdate(); | 4075 | parentPrim.ScheduleGroupForFullUpdate(); |
3708 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 4076 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3711,12 +4079,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3711 | { | 4079 | { |
3712 | SceneObjectPart newRoot = parts[0]; | 4080 | SceneObjectPart newRoot = parts[0]; |
3713 | parts.Remove(newRoot); | 4081 | parts.Remove(newRoot); |
3714 | foreach (SceneObjectPart part in parts) | 4082 | |
4083 | try | ||
3715 | { | 4084 | { |
3716 | // Required for linking | 4085 | foreach (SceneObjectPart part in parts) |
3717 | part.ClearUpdateSchedule(); | 4086 | { |
3718 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 4087 | part.ClearUpdateSchedule(); |
4088 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
4089 | } | ||
3719 | } | 4090 | } |
4091 | finally | ||
4092 | { | ||
4093 | } | ||
4094 | |||
4095 | |||
3720 | newRoot.ParentGroup.HasGroupChanged = true; | 4096 | newRoot.ParentGroup.HasGroupChanged = true; |
3721 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 4097 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3722 | } | 4098 | } |
@@ -3736,6 +4112,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3736 | public void llBreakAllLinks() | 4112 | public void llBreakAllLinks() |
3737 | { | 4113 | { |
3738 | m_host.AddScriptLPS(1); | 4114 | m_host.AddScriptLPS(1); |
4115 | |||
4116 | TaskInventoryItem item = m_item; | ||
4117 | |||
4118 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | ||
4119 | && !m_automaticLinkPermission) | ||
4120 | { | ||
4121 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | ||
4122 | return; | ||
4123 | } | ||
4124 | |||
3739 | SceneObjectGroup parentPrim = m_host.ParentGroup; | 4125 | SceneObjectGroup parentPrim = m_host.ParentGroup; |
3740 | if (parentPrim.AttachmentPoint != 0) | 4126 | if (parentPrim.AttachmentPoint != 0) |
3741 | return; // Fail silently if attached | 4127 | return; // Fail silently if attached |
@@ -3755,47 +4141,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3755 | public LSL_String llGetLinkKey(int linknum) | 4141 | public LSL_String llGetLinkKey(int linknum) |
3756 | { | 4142 | { |
3757 | m_host.AddScriptLPS(1); | 4143 | m_host.AddScriptLPS(1); |
3758 | 4144 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | |
3759 | if (linknum < 0) | 4145 | if (part != null) |
3760 | { | ||
3761 | if (linknum == ScriptBaseClass.LINK_THIS) | ||
3762 | return m_host.UUID.ToString(); | ||
3763 | else | ||
3764 | return ScriptBaseClass.NULL_KEY; | ||
3765 | } | ||
3766 | |||
3767 | int actualPrimCount = m_host.ParentGroup.PrimCount; | ||
3768 | List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars(); | ||
3769 | int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count; | ||
3770 | |||
3771 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single | ||
3772 | // prim that has any avatars sat upon it (in which case the root prim is link 1). | ||
3773 | if (linknum == 0) | ||
3774 | { | ||
3775 | if (actualPrimCount == 1 && sittingAvatarIds.Count == 0) | ||
3776 | return m_host.UUID.ToString(); | ||
3777 | |||
3778 | return ScriptBaseClass.NULL_KEY; | ||
3779 | } | ||
3780 | // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but | ||
3781 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). | ||
3782 | else if (linknum == 1 && actualPrimCount == 1) | ||
3783 | { | ||
3784 | if (sittingAvatarIds.Count > 0) | ||
3785 | return m_host.ParentGroup.RootPart.UUID.ToString(); | ||
3786 | else | ||
3787 | return ScriptBaseClass.NULL_KEY; | ||
3788 | } | ||
3789 | else if (linknum <= adjustedPrimCount) | ||
3790 | { | 4146 | { |
3791 | if (linknum <= actualPrimCount) | 4147 | return part.UUID.ToString(); |
3792 | return m_host.ParentGroup.GetLinkNumPart(linknum).UUID.ToString(); | ||
3793 | else | ||
3794 | return sittingAvatarIds[linknum - actualPrimCount - 1].ToString(); | ||
3795 | } | 4148 | } |
3796 | else | 4149 | else |
3797 | { | 4150 | { |
3798 | return ScriptBaseClass.NULL_KEY; | 4151 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) |
4152 | { | ||
4153 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
4154 | |||
4155 | if (linknum < 0) | ||
4156 | return UUID.Zero.ToString(); | ||
4157 | |||
4158 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); | ||
4159 | if (avatars.Count > linknum) | ||
4160 | { | ||
4161 | return avatars[linknum].UUID.ToString(); | ||
4162 | } | ||
4163 | } | ||
4164 | return UUID.Zero.ToString(); | ||
3799 | } | 4165 | } |
3800 | } | 4166 | } |
3801 | 4167 | ||
@@ -3898,17 +4264,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3898 | m_host.AddScriptLPS(1); | 4264 | m_host.AddScriptLPS(1); |
3899 | int count = 0; | 4265 | int count = 0; |
3900 | 4266 | ||
3901 | lock (m_host.TaskInventory) | 4267 | m_host.TaskInventory.LockItemsForRead(true); |
4268 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3902 | { | 4269 | { |
3903 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4270 | if (inv.Value.Type == type || type == -1) |
3904 | { | 4271 | { |
3905 | if (inv.Value.Type == type || type == -1) | 4272 | count = count + 1; |
3906 | { | ||
3907 | count = count + 1; | ||
3908 | } | ||
3909 | } | 4273 | } |
3910 | } | 4274 | } |
3911 | 4275 | ||
4276 | m_host.TaskInventory.LockItemsForRead(false); | ||
3912 | return count; | 4277 | return count; |
3913 | } | 4278 | } |
3914 | 4279 | ||
@@ -3917,16 +4282,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3917 | m_host.AddScriptLPS(1); | 4282 | m_host.AddScriptLPS(1); |
3918 | ArrayList keys = new ArrayList(); | 4283 | ArrayList keys = new ArrayList(); |
3919 | 4284 | ||
3920 | lock (m_host.TaskInventory) | 4285 | m_host.TaskInventory.LockItemsForRead(true); |
4286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3921 | { | 4287 | { |
3922 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4288 | if (inv.Value.Type == type || type == -1) |
3923 | { | 4289 | { |
3924 | if (inv.Value.Type == type || type == -1) | 4290 | keys.Add(inv.Value.Name); |
3925 | { | ||
3926 | keys.Add(inv.Value.Name); | ||
3927 | } | ||
3928 | } | 4291 | } |
3929 | } | 4292 | } |
4293 | m_host.TaskInventory.LockItemsForRead(false); | ||
3930 | 4294 | ||
3931 | if (keys.Count == 0) | 4295 | if (keys.Count == 0) |
3932 | { | 4296 | { |
@@ -3964,7 +4328,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3964 | if (item == null) | 4328 | if (item == null) |
3965 | { | 4329 | { |
3966 | llSay(0, String.Format("Could not find object '{0}'", inventory)); | 4330 | llSay(0, String.Format("Could not find object '{0}'", inventory)); |
3967 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4331 | return; |
4332 | // throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | ||
3968 | } | 4333 | } |
3969 | 4334 | ||
3970 | UUID objId = item.ItemID; | 4335 | UUID objId = item.ItemID; |
@@ -3992,33 +4357,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3992 | return; | 4357 | return; |
3993 | } | 4358 | } |
3994 | } | 4359 | } |
4360 | |||
3995 | // destination is an avatar | 4361 | // destination is an avatar |
3996 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4362 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
3997 | 4363 | ||
3998 | if (agentItem == null) | 4364 | if (agentItem == null) |
3999 | return; | 4365 | return; |
4000 | 4366 | ||
4001 | if (m_TransferModule != null) | 4367 | byte[] bucket = new byte[1]; |
4002 | { | 4368 | bucket[0] = (byte)item.Type; |
4003 | byte[] bucket = new byte[1]; | 4369 | //byte[] objBytes = agentItem.ID.GetBytes(); |
4004 | bucket[0] = (byte)item.Type; | 4370 | //Array.Copy(objBytes, 0, bucket, 1, 16); |
4005 | 4371 | ||
4006 | GridInstantMessage msg = new GridInstantMessage(World, | 4372 | GridInstantMessage msg = new GridInstantMessage(World, |
4007 | m_host.OwnerID, m_host.Name, destId, | 4373 | m_host.OwnerID, m_host.Name, destId, |
4008 | (byte)InstantMessageDialog.TaskInventoryOffered, | 4374 | (byte)InstantMessageDialog.TaskInventoryOffered, |
4009 | false, item.Name+". "+m_host.Name+" is located at "+ | 4375 | false, item.Name+". "+m_host.Name+" is located at "+ |
4010 | World.RegionInfo.RegionName+" "+ | 4376 | World.RegionInfo.RegionName+" "+ |
4011 | m_host.AbsolutePosition.ToString(), | 4377 | m_host.AbsolutePosition.ToString(), |
4012 | agentItem.ID, true, m_host.AbsolutePosition, | 4378 | agentItem.ID, true, m_host.AbsolutePosition, |
4013 | bucket, true); | 4379 | bucket, true); |
4014 | 4380 | ||
4015 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4381 | ScenePresence sp; |
4016 | } | ||
4017 | 4382 | ||
4383 | if (World.TryGetScenePresence(destId, out sp)) | ||
4384 | { | ||
4385 | sp.ControllingClient.SendInstantMessage(msg); | ||
4386 | } | ||
4387 | else | ||
4388 | { | ||
4389 | if (m_TransferModule != null) | ||
4390 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | ||
4391 | } | ||
4392 | |||
4393 | //This delay should only occur when giving inventory to avatars. | ||
4018 | ScriptSleep(3000); | 4394 | ScriptSleep(3000); |
4019 | } | 4395 | } |
4020 | } | 4396 | } |
4021 | 4397 | ||
4398 | [DebuggerNonUserCode] | ||
4022 | public void llRemoveInventory(string name) | 4399 | public void llRemoveInventory(string name) |
4023 | { | 4400 | { |
4024 | m_host.AddScriptLPS(1); | 4401 | m_host.AddScriptLPS(1); |
@@ -4073,109 +4450,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4073 | { | 4450 | { |
4074 | m_host.AddScriptLPS(1); | 4451 | m_host.AddScriptLPS(1); |
4075 | 4452 | ||
4076 | UUID uuid = (UUID)id; | 4453 | UUID uuid; |
4077 | PresenceInfo pinfo = null; | 4454 | if (UUID.TryParse(id, out uuid)) |
4078 | UserAccount account; | ||
4079 | |||
4080 | UserInfoCacheEntry ce; | ||
4081 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
4082 | { | 4455 | { |
4083 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4456 | PresenceInfo pinfo = null; |
4084 | if (account == null) | 4457 | UserAccount account; |
4458 | |||
4459 | UserInfoCacheEntry ce; | ||
4460 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
4085 | { | 4461 | { |
4086 | m_userInfoCache[uuid] = null; // Cache negative | 4462 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
4087 | return UUID.Zero.ToString(); | 4463 | if (account == null) |
4088 | } | 4464 | { |
4465 | m_userInfoCache[uuid] = null; // Cache negative | ||
4466 | return UUID.Zero.ToString(); | ||
4467 | } | ||
4089 | 4468 | ||
4090 | 4469 | ||
4091 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4470 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4092 | if (pinfos != null && pinfos.Length > 0) | 4471 | if (pinfos != null && pinfos.Length > 0) |
4093 | { | ||
4094 | foreach (PresenceInfo p in pinfos) | ||
4095 | { | 4472 | { |
4096 | if (p.RegionID != UUID.Zero) | 4473 | foreach (PresenceInfo p in pinfos) |
4097 | { | 4474 | { |
4098 | pinfo = p; | 4475 | if (p.RegionID != UUID.Zero) |
4476 | { | ||
4477 | pinfo = p; | ||
4478 | } | ||
4099 | } | 4479 | } |
4100 | } | 4480 | } |
4101 | } | ||
4102 | 4481 | ||
4103 | ce = new UserInfoCacheEntry(); | 4482 | ce = new UserInfoCacheEntry(); |
4104 | ce.time = Util.EnvironmentTickCount(); | 4483 | ce.time = Util.EnvironmentTickCount(); |
4105 | ce.account = account; | 4484 | ce.account = account; |
4106 | ce.pinfo = pinfo; | 4485 | ce.pinfo = pinfo; |
4107 | } | 4486 | m_userInfoCache[uuid] = ce; |
4108 | else | 4487 | } |
4109 | { | 4488 | else |
4110 | if (ce == null) | 4489 | { |
4111 | return UUID.Zero.ToString(); | 4490 | if (ce == null) |
4491 | return UUID.Zero.ToString(); | ||
4112 | 4492 | ||
4113 | account = ce.account; | 4493 | account = ce.account; |
4114 | pinfo = ce.pinfo; | 4494 | pinfo = ce.pinfo; |
4115 | } | 4495 | } |
4116 | 4496 | ||
4117 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | 4497 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) |
4118 | { | ||
4119 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | ||
4120 | if (pinfos != null && pinfos.Length > 0) | ||
4121 | { | 4498 | { |
4122 | foreach (PresenceInfo p in pinfos) | 4499 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4500 | if (pinfos != null && pinfos.Length > 0) | ||
4123 | { | 4501 | { |
4124 | if (p.RegionID != UUID.Zero) | 4502 | foreach (PresenceInfo p in pinfos) |
4125 | { | 4503 | { |
4126 | pinfo = p; | 4504 | if (p.RegionID != UUID.Zero) |
4505 | { | ||
4506 | pinfo = p; | ||
4507 | } | ||
4127 | } | 4508 | } |
4128 | } | 4509 | } |
4129 | } | 4510 | else |
4130 | else | 4511 | pinfo = null; |
4131 | pinfo = null; | ||
4132 | 4512 | ||
4133 | ce.time = Util.EnvironmentTickCount(); | 4513 | ce.time = Util.EnvironmentTickCount(); |
4134 | ce.pinfo = pinfo; | 4514 | ce.pinfo = pinfo; |
4135 | } | 4515 | } |
4136 | 4516 | ||
4137 | string reply = String.Empty; | 4517 | string reply = String.Empty; |
4138 | 4518 | ||
4139 | switch (data) | 4519 | switch (data) |
4140 | { | 4520 | { |
4141 | case 1: // DATA_ONLINE (0|1) | 4521 | case 1: // DATA_ONLINE (0|1) |
4142 | if (pinfo != null && pinfo.RegionID != UUID.Zero) | 4522 | if (pinfo != null && pinfo.RegionID != UUID.Zero) |
4143 | reply = "1"; | 4523 | reply = "1"; |
4144 | else | 4524 | else |
4145 | reply = "0"; | 4525 | reply = "0"; |
4146 | break; | 4526 | break; |
4147 | case 2: // DATA_NAME (First Last) | 4527 | case 2: // DATA_NAME (First Last) |
4148 | reply = account.FirstName + " " + account.LastName; | 4528 | reply = account.FirstName + " " + account.LastName; |
4149 | break; | 4529 | break; |
4150 | case 3: // DATA_BORN (YYYY-MM-DD) | 4530 | case 3: // DATA_BORN (YYYY-MM-DD) |
4151 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | 4531 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); |
4152 | born = born.AddSeconds(account.Created); | 4532 | born = born.AddSeconds(account.Created); |
4153 | reply = born.ToString("yyyy-MM-dd"); | 4533 | reply = born.ToString("yyyy-MM-dd"); |
4154 | break; | 4534 | break; |
4155 | case 4: // DATA_RATING (0,0,0,0,0,0) | 4535 | case 4: // DATA_RATING (0,0,0,0,0,0) |
4156 | reply = "0,0,0,0,0,0"; | 4536 | reply = "0,0,0,0,0,0"; |
4157 | break; | 4537 | break; |
4158 | case 7: // DATA_USERLEVEL (integer) | 4538 | case 8: // DATA_PAYINFO (0|1|2|3) |
4159 | reply = account.UserLevel.ToString(); | 4539 | reply = "0"; |
4160 | break; | 4540 | break; |
4161 | case 8: // DATA_PAYINFO (0|1|2|3) | 4541 | default: |
4162 | reply = "0"; | 4542 | return UUID.Zero.ToString(); // Raise no event |
4163 | break; | 4543 | } |
4164 | default: | ||
4165 | return UUID.Zero.ToString(); // Raise no event | ||
4166 | } | ||
4167 | 4544 | ||
4168 | UUID rq = UUID.Random(); | 4545 | UUID rq = UUID.Random(); |
4169 | 4546 | ||
4170 | UUID tid = AsyncCommands. | 4547 | UUID tid = AsyncCommands. |
4171 | DataserverPlugin.RegisterRequest(m_host.LocalId, | 4548 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4172 | m_item.ItemID, rq.ToString()); | 4549 | m_item.ItemID, rq.ToString()); |
4173 | 4550 | ||
4174 | AsyncCommands. | 4551 | AsyncCommands. |
4175 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 4552 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
4176 | 4553 | ||
4177 | ScriptSleep(100); | 4554 | ScriptSleep(100); |
4178 | return tid.ToString(); | 4555 | return tid.ToString(); |
4556 | } | ||
4557 | else | ||
4558 | { | ||
4559 | ShoutError("Invalid UUID passed to llRequestAgentData."); | ||
4560 | } | ||
4561 | return ""; | ||
4179 | } | 4562 | } |
4180 | 4563 | ||
4181 | public LSL_String llRequestInventoryData(string name) | 4564 | public LSL_String llRequestInventoryData(string name) |
@@ -4232,13 +4615,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4232 | if (UUID.TryParse(agent, out agentId)) | 4615 | if (UUID.TryParse(agent, out agentId)) |
4233 | { | 4616 | { |
4234 | ScenePresence presence = World.GetScenePresence(agentId); | 4617 | ScenePresence presence = World.GetScenePresence(agentId); |
4235 | if (presence != null) | 4618 | if (presence != null && presence.PresenceType != PresenceType.Npc) |
4236 | { | 4619 | { |
4620 | // agent must not be a god | ||
4621 | if (presence.UserLevel >= 200) return; | ||
4622 | |||
4237 | // agent must be over the owners land | 4623 | // agent must be over the owners land |
4238 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4624 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4239 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4625 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
4240 | { | 4626 | { |
4241 | World.TeleportClientHome(agentId, presence.ControllingClient); | 4627 | if (!World.TeleportClientHome(agentId, presence.ControllingClient)) |
4628 | { | ||
4629 | // They can't be teleported home for some reason | ||
4630 | GridRegion regionInfo = World.GridService.GetRegionByUUID(UUID.Zero, new UUID("2b02daac-e298-42fa-9a75-f488d37896e6")); | ||
4631 | if (regionInfo != null) | ||
4632 | { | ||
4633 | World.RequestTeleportLocation( | ||
4634 | presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero, | ||
4635 | (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); | ||
4636 | } | ||
4637 | } | ||
4242 | } | 4638 | } |
4243 | } | 4639 | } |
4244 | } | 4640 | } |
@@ -4345,7 +4741,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4345 | UUID av = new UUID(); | 4741 | UUID av = new UUID(); |
4346 | if (!UUID.TryParse(agent,out av)) | 4742 | if (!UUID.TryParse(agent,out av)) |
4347 | { | 4743 | { |
4348 | LSLError("First parameter to llDialog needs to be a key"); | 4744 | //LSLError("First parameter to llDialog needs to be a key"); |
4349 | return; | 4745 | return; |
4350 | } | 4746 | } |
4351 | 4747 | ||
@@ -4377,10 +4773,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4377 | public void llCollisionSound(string impact_sound, double impact_volume) | 4773 | public void llCollisionSound(string impact_sound, double impact_volume) |
4378 | { | 4774 | { |
4379 | m_host.AddScriptLPS(1); | 4775 | m_host.AddScriptLPS(1); |
4380 | 4776 | ||
4777 | if(impact_sound == "") | ||
4778 | { | ||
4779 | m_host.CollisionSoundVolume = (float)impact_volume; | ||
4780 | m_host.CollisionSound = m_host.invalidCollisionSoundUUID; | ||
4781 | m_host.CollisionSoundType = 0; | ||
4782 | return; | ||
4783 | } | ||
4381 | // TODO: Parameter check logic required. | 4784 | // TODO: Parameter check logic required. |
4382 | m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); | 4785 | m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); |
4383 | m_host.CollisionSoundVolume = (float)impact_volume; | 4786 | m_host.CollisionSoundVolume = (float)impact_volume; |
4787 | m_host.CollisionSoundType = 1; | ||
4384 | } | 4788 | } |
4385 | 4789 | ||
4386 | public LSL_String llGetAnimation(string id) | 4790 | public LSL_String llGetAnimation(string id) |
@@ -4394,14 +4798,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4394 | 4798 | ||
4395 | if (m_host.RegionHandle == presence.RegionHandle) | 4799 | if (m_host.RegionHandle == presence.RegionHandle) |
4396 | { | 4800 | { |
4397 | Dictionary<UUID, string> animationstateNames = DefaultAvatarAnimations.AnimStateNames; | ||
4398 | |||
4399 | if (presence != null) | 4801 | if (presence != null) |
4400 | { | 4802 | { |
4401 | AnimationSet currentAnims = presence.Animator.Animations; | 4803 | if (presence.SitGround) |
4402 | string currentAnimationState = String.Empty; | 4804 | return "Sitting on Ground"; |
4403 | if (animationstateNames.TryGetValue(currentAnims.ImplicitDefaultAnimation.AnimID, out currentAnimationState)) | 4805 | if (presence.ParentID != 0 || presence.ParentUUID != UUID.Zero) |
4404 | return currentAnimationState; | 4806 | return "Sitting"; |
4807 | |||
4808 | string movementAnimation = presence.Animator.CurrentMovementAnimation; | ||
4809 | string lslMovementAnimation; | ||
4810 | |||
4811 | if (MovementAnimationsForLSL.TryGetValue(movementAnimation, out lslMovementAnimation)) | ||
4812 | return lslMovementAnimation; | ||
4405 | } | 4813 | } |
4406 | } | 4814 | } |
4407 | 4815 | ||
@@ -4548,7 +4956,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4548 | { | 4956 | { |
4549 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); | 4957 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); |
4550 | float distance_term = distance * distance * distance; // Script Energy | 4958 | float distance_term = distance * distance * distance; // Script Energy |
4551 | float pusher_mass = m_host.GetMass(); | 4959 | // use total object mass and not part |
4960 | float pusher_mass = m_host.ParentGroup.GetMass(); | ||
4552 | 4961 | ||
4553 | float PUSH_ATTENUATION_DISTANCE = 17f; | 4962 | float PUSH_ATTENUATION_DISTANCE = 17f; |
4554 | float PUSH_ATTENUATION_SCALE = 5f; | 4963 | float PUSH_ATTENUATION_SCALE = 5f; |
@@ -4798,6 +5207,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4798 | { | 5207 | { |
4799 | return item.AssetID.ToString(); | 5208 | return item.AssetID.ToString(); |
4800 | } | 5209 | } |
5210 | m_host.TaskInventory.LockItemsForRead(false); | ||
4801 | 5211 | ||
4802 | return UUID.Zero.ToString(); | 5212 | return UUID.Zero.ToString(); |
4803 | } | 5213 | } |
@@ -4950,14 +5360,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4950 | { | 5360 | { |
4951 | m_host.AddScriptLPS(1); | 5361 | m_host.AddScriptLPS(1); |
4952 | 5362 | ||
4953 | if (src == null) | 5363 | return src.Length; |
4954 | { | ||
4955 | return 0; | ||
4956 | } | ||
4957 | else | ||
4958 | { | ||
4959 | return src.Length; | ||
4960 | } | ||
4961 | } | 5364 | } |
4962 | 5365 | ||
4963 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5366 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -5028,7 +5431,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5028 | else if (src.Data[index] is LSL_Float) | 5431 | else if (src.Data[index] is LSL_Float) |
5029 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); | 5432 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); |
5030 | else if (src.Data[index] is LSL_String) | 5433 | else if (src.Data[index] is LSL_String) |
5031 | return Convert.ToDouble(((LSL_String)src.Data[index]).m_string); | 5434 | { |
5435 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5436 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5437 | if (m != Match.Empty) | ||
5438 | { | ||
5439 | str = m.Value; | ||
5440 | double d = 0.0; | ||
5441 | if (!Double.TryParse(str, out d)) | ||
5442 | return 0.0; | ||
5443 | |||
5444 | return d; | ||
5445 | } | ||
5446 | return 0.0; | ||
5447 | } | ||
5032 | return Convert.ToDouble(src.Data[index]); | 5448 | return Convert.ToDouble(src.Data[index]); |
5033 | } | 5449 | } |
5034 | catch (FormatException) | 5450 | catch (FormatException) |
@@ -5070,7 +5486,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5070 | // for completion and should LSL_Key ever be implemented | 5486 | // for completion and should LSL_Key ever be implemented |
5071 | // as it's own struct | 5487 | // as it's own struct |
5072 | else if (!(src.Data[index] is LSL_String || | 5488 | else if (!(src.Data[index] is LSL_String || |
5073 | src.Data[index] is LSL_Key)) | 5489 | src.Data[index] is LSL_Key || |
5490 | src.Data[index] is String)) | ||
5074 | { | 5491 | { |
5075 | return ""; | 5492 | return ""; |
5076 | } | 5493 | } |
@@ -5328,7 +5745,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5328 | } | 5745 | } |
5329 | } | 5746 | } |
5330 | } | 5747 | } |
5331 | else { | 5748 | else |
5749 | { | ||
5332 | object[] array = new object[src.Length]; | 5750 | object[] array = new object[src.Length]; |
5333 | Array.Copy(src.Data, 0, array, 0, src.Length); | 5751 | Array.Copy(src.Data, 0, array, 0, src.Length); |
5334 | result = new LSL_List(array); | 5752 | result = new LSL_List(array); |
@@ -5435,7 +5853,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5435 | public LSL_Integer llGetRegionAgentCount() | 5853 | public LSL_Integer llGetRegionAgentCount() |
5436 | { | 5854 | { |
5437 | m_host.AddScriptLPS(1); | 5855 | m_host.AddScriptLPS(1); |
5438 | return new LSL_Integer(World.GetRootAgentCount()); | 5856 | |
5857 | int count = 0; | ||
5858 | World.ForEachRootScenePresence(delegate(ScenePresence sp) { | ||
5859 | count++; | ||
5860 | }); | ||
5861 | |||
5862 | return new LSL_Integer(count); | ||
5439 | } | 5863 | } |
5440 | 5864 | ||
5441 | public LSL_Vector llGetRegionCorner() | 5865 | public LSL_Vector llGetRegionCorner() |
@@ -5676,6 +6100,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5676 | flags |= ScriptBaseClass.AGENT_AWAY; | 6100 | flags |= ScriptBaseClass.AGENT_AWAY; |
5677 | } | 6101 | } |
5678 | 6102 | ||
6103 | UUID busy = new UUID("efcf670c-2d18-8128-973a-034ebc806b67"); | ||
6104 | UUID[] anims = agent.Animator.GetAnimationArray(); | ||
6105 | if (Array.Exists<UUID>(anims, a => { return a == busy; })) | ||
6106 | { | ||
6107 | flags |= ScriptBaseClass.AGENT_BUSY; | ||
6108 | } | ||
6109 | |||
5679 | // seems to get unset, even if in mouselook, when avatar is sitting on a prim??? | 6110 | // seems to get unset, even if in mouselook, when avatar is sitting on a prim??? |
5680 | if ((agent.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | 6111 | if ((agent.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) |
5681 | { | 6112 | { |
@@ -5723,6 +6154,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5723 | flags |= ScriptBaseClass.AGENT_SITTING; | 6154 | flags |= ScriptBaseClass.AGENT_SITTING; |
5724 | } | 6155 | } |
5725 | 6156 | ||
6157 | if (agent.Appearance.VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MALE] > 0) | ||
6158 | { | ||
6159 | flags |= ScriptBaseClass.AGENT_MALE; | ||
6160 | } | ||
6161 | |||
5726 | return flags; | 6162 | return flags; |
5727 | } | 6163 | } |
5728 | 6164 | ||
@@ -5870,9 +6306,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5870 | 6306 | ||
5871 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6307 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5872 | 6308 | ||
5873 | foreach (SceneObjectPart part in parts) | 6309 | try |
6310 | { | ||
6311 | foreach (SceneObjectPart part in parts) | ||
6312 | { | ||
6313 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6314 | } | ||
6315 | } | ||
6316 | finally | ||
5874 | { | 6317 | { |
5875 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5876 | } | 6318 | } |
5877 | } | 6319 | } |
5878 | 6320 | ||
@@ -5926,13 +6368,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5926 | 6368 | ||
5927 | if (m_host.OwnerID == land.LandData.OwnerID) | 6369 | if (m_host.OwnerID == land.LandData.OwnerID) |
5928 | { | 6370 | { |
5929 | World.TeleportClientHome(agentID, presence.ControllingClient); | 6371 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6372 | presence.TeleportWithMomentum(pos, null); | ||
6373 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
5930 | } | 6374 | } |
5931 | } | 6375 | } |
5932 | } | 6376 | } |
5933 | ScriptSleep(5000); | 6377 | ScriptSleep(5000); |
5934 | } | 6378 | } |
5935 | 6379 | ||
6380 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
6381 | { | ||
6382 | return ParseString2List(str, separators, in_spacers, false); | ||
6383 | } | ||
6384 | |||
5936 | public LSL_Integer llOverMyLand(string id) | 6385 | public LSL_Integer llOverMyLand(string id) |
5937 | { | 6386 | { |
5938 | m_host.AddScriptLPS(1); | 6387 | m_host.AddScriptLPS(1); |
@@ -5986,25 +6435,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5986 | } | 6435 | } |
5987 | else | 6436 | else |
5988 | { | 6437 | { |
5989 | agentSize = new LSL_Vector(0.45, 0.6, avatar.Appearance.AvatarHeight); | 6438 | // agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight); |
6439 | Vector3 s = avatar.Appearance.AvatarSize; | ||
6440 | agentSize = new LSL_Vector(s.X, s.Y, s.Z); | ||
5990 | } | 6441 | } |
5991 | return agentSize; | 6442 | return agentSize; |
5992 | } | 6443 | } |
5993 | 6444 | ||
5994 | public LSL_Integer llSameGroup(string agent) | 6445 | public LSL_Integer llSameGroup(string id) |
5995 | { | 6446 | { |
5996 | m_host.AddScriptLPS(1); | 6447 | m_host.AddScriptLPS(1); |
5997 | UUID agentId = new UUID(); | 6448 | UUID uuid = new UUID(); |
5998 | if (!UUID.TryParse(agent, out agentId)) | 6449 | if (!UUID.TryParse(id, out uuid)) |
5999 | return new LSL_Integer(0); | 6450 | return new LSL_Integer(0); |
6000 | ScenePresence presence = World.GetScenePresence(agentId); | 6451 | |
6001 | if (presence == null || presence.IsChildAgent) // Return flase for child agents | 6452 | // Check if it's a group key |
6002 | return new LSL_Integer(0); | 6453 | if (uuid == m_host.ParentGroup.RootPart.GroupID) |
6003 | IClientAPI client = presence.ControllingClient; | ||
6004 | if (m_host.GroupID == client.ActiveGroupId) | ||
6005 | return new LSL_Integer(1); | 6454 | return new LSL_Integer(1); |
6006 | else | 6455 | |
6456 | // We got passed a UUID.Zero | ||
6457 | if (uuid == UUID.Zero) | ||
6458 | return new LSL_Integer(0); | ||
6459 | |||
6460 | // Handle the case where id names an avatar | ||
6461 | ScenePresence presence = World.GetScenePresence(uuid); | ||
6462 | if (presence != null) | ||
6463 | { | ||
6464 | if (presence.IsChildAgent) | ||
6465 | return new LSL_Integer(0); | ||
6466 | |||
6467 | IClientAPI client = presence.ControllingClient; | ||
6468 | if (m_host.ParentGroup.RootPart.GroupID == client.ActiveGroupId) | ||
6469 | return new LSL_Integer(1); | ||
6470 | |||
6471 | return new LSL_Integer(0); | ||
6472 | } | ||
6473 | |||
6474 | // Handle object case | ||
6475 | SceneObjectPart part = World.GetSceneObjectPart(uuid); | ||
6476 | if (part != null) | ||
6477 | { | ||
6478 | // This will handle both deed and non-deed and also the no | ||
6479 | // group case | ||
6480 | if (part.ParentGroup.RootPart.GroupID == m_host.ParentGroup.RootPart.GroupID) | ||
6481 | return new LSL_Integer(1); | ||
6482 | |||
6007 | return new LSL_Integer(0); | 6483 | return new LSL_Integer(0); |
6484 | } | ||
6485 | |||
6486 | return new LSL_Integer(0); | ||
6008 | } | 6487 | } |
6009 | 6488 | ||
6010 | public void llUnSit(string id) | 6489 | public void llUnSit(string id) |
@@ -6129,7 +6608,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6129 | return m_host.ParentGroup.AttachmentPoint; | 6608 | return m_host.ParentGroup.AttachmentPoint; |
6130 | } | 6609 | } |
6131 | 6610 | ||
6132 | public LSL_Integer llGetFreeMemory() | 6611 | public virtual LSL_Integer llGetFreeMemory() |
6133 | { | 6612 | { |
6134 | m_host.AddScriptLPS(1); | 6613 | m_host.AddScriptLPS(1); |
6135 | // Make scripts designed for LSO happy | 6614 | // Make scripts designed for LSO happy |
@@ -6561,6 +7040,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6561 | 7040 | ||
6562 | protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) | 7041 | protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) |
6563 | { | 7042 | { |
7043 | // LSL quaternions can normalize to 0, normal Quaternions can't. | ||
7044 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | ||
7045 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 | ||
7046 | |||
6564 | part.SitTargetPosition = offset; | 7047 | part.SitTargetPosition = offset; |
6565 | part.SitTargetOrientation = rot; | 7048 | part.SitTargetOrientation = rot; |
6566 | part.ParentGroup.HasGroupChanged = true; | 7049 | part.ParentGroup.HasGroupChanged = true; |
@@ -6746,13 +7229,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6746 | UUID av = new UUID(); | 7229 | UUID av = new UUID(); |
6747 | if (!UUID.TryParse(avatar,out av)) | 7230 | if (!UUID.TryParse(avatar,out av)) |
6748 | { | 7231 | { |
6749 | LSLError("First parameter to llDialog needs to be a key"); | 7232 | //LSLError("First parameter to llDialog needs to be a key"); |
6750 | return; | 7233 | return; |
6751 | } | 7234 | } |
6752 | if (buttons.Length < 1) | 7235 | if (buttons.Length < 1) |
6753 | { | 7236 | { |
6754 | LSLError("No less than 1 button can be shown"); | 7237 | buttons.Add("OK"); |
6755 | return; | ||
6756 | } | 7238 | } |
6757 | if (buttons.Length > 12) | 7239 | if (buttons.Length > 12) |
6758 | { | 7240 | { |
@@ -6769,7 +7251,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6769 | } | 7251 | } |
6770 | if (buttons.Data[i].ToString().Length > 24) | 7252 | if (buttons.Data[i].ToString().Length > 24) |
6771 | { | 7253 | { |
6772 | LSLError("button label cannot be longer than 24 characters"); | 7254 | llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters"); |
6773 | return; | 7255 | return; |
6774 | } | 7256 | } |
6775 | buts[i] = buttons.Data[i].ToString(); | 7257 | buts[i] = buttons.Data[i].ToString(); |
@@ -6836,9 +7318,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6836 | return; | 7318 | return; |
6837 | } | 7319 | } |
6838 | 7320 | ||
6839 | // the rest of the permission checks are done in RezScript, so check the pin there as well | 7321 | SceneObjectPart dest = World.GetSceneObjectPart(destId); |
6840 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); | 7322 | if (dest != null) |
7323 | { | ||
7324 | if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) | ||
7325 | { | ||
7326 | // the rest of the permission checks are done in RezScript, so check the pin there as well | ||
7327 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); | ||
6841 | 7328 | ||
7329 | if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0) | ||
7330 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
7331 | } | ||
7332 | } | ||
6842 | // this will cause the delay even if the script pin or permissions were wrong - seems ok | 7333 | // this will cause the delay even if the script pin or permissions were wrong - seems ok |
6843 | ScriptSleep(3000); | 7334 | ScriptSleep(3000); |
6844 | } | 7335 | } |
@@ -6912,19 +7403,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6912 | public LSL_String llMD5String(string src, int nonce) | 7403 | public LSL_String llMD5String(string src, int nonce) |
6913 | { | 7404 | { |
6914 | m_host.AddScriptLPS(1); | 7405 | m_host.AddScriptLPS(1); |
6915 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); | 7406 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); |
6916 | } | 7407 | } |
6917 | 7408 | ||
6918 | public LSL_String llSHA1String(string src) | 7409 | public LSL_String llSHA1String(string src) |
6919 | { | 7410 | { |
6920 | m_host.AddScriptLPS(1); | 7411 | m_host.AddScriptLPS(1); |
6921 | return Util.SHA1Hash(src).ToLower(); | 7412 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
6922 | } | 7413 | } |
6923 | 7414 | ||
6924 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) | 7415 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) |
6925 | { | 7416 | { |
6926 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7417 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
6927 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7418 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7419 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7420 | return shapeBlock; | ||
6928 | 7421 | ||
6929 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 7422 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6930 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 7423 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -7029,6 +7522,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7029 | // Prim type box, cylinder and prism. | 7522 | // Prim type box, cylinder and prism. |
7030 | 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) | 7523 | 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) |
7031 | { | 7524 | { |
7525 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7526 | return; | ||
7527 | |||
7032 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7528 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
7033 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7529 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7034 | 7530 | ||
@@ -7082,6 +7578,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7082 | // Prim type sphere. | 7578 | // Prim type sphere. |
7083 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) | 7579 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) |
7084 | { | 7580 | { |
7581 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7582 | return; | ||
7583 | |||
7085 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7584 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7086 | 7585 | ||
7087 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); | 7586 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
@@ -7123,6 +7622,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7123 | // Prim type torus, tube and ring. | 7622 | // Prim type torus, tube and ring. |
7124 | 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) | 7623 | 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) |
7125 | { | 7624 | { |
7625 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7626 | return; | ||
7627 | |||
7126 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7628 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
7127 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7629 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7128 | 7630 | ||
@@ -7258,6 +7760,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7258 | // Prim type sculpt. | 7760 | // Prim type sculpt. |
7259 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) | 7761 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) |
7260 | { | 7762 | { |
7763 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7764 | return; | ||
7765 | |||
7261 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7766 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7262 | UUID sculptId; | 7767 | UUID sculptId; |
7263 | 7768 | ||
@@ -7282,7 +7787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7282 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) | 7787 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) |
7283 | { | 7788 | { |
7284 | // default | 7789 | // default |
7285 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7790 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
7286 | } | 7791 | } |
7287 | 7792 | ||
7288 | part.Shape.SetSculptProperties((byte)type, sculptId); | 7793 | part.Shape.SetSculptProperties((byte)type, sculptId); |
@@ -7299,48 +7804,130 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7299 | ScriptSleep(200); | 7804 | ScriptSleep(200); |
7300 | } | 7805 | } |
7301 | 7806 | ||
7302 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7807 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
7303 | { | 7808 | { |
7304 | m_host.AddScriptLPS(1); | 7809 | m_host.AddScriptLPS(1); |
7305 | 7810 | ||
7306 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); | 7811 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); |
7812 | } | ||
7307 | 7813 | ||
7308 | ScriptSleep(200); | 7814 | private void setLinkPrimParams(int linknumber, LSL_List rules, string originFunc) |
7815 | { | ||
7816 | List<object> parts = new List<object>(); | ||
7817 | List<SceneObjectPart> prims = GetLinkParts(linknumber); | ||
7818 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7819 | foreach (SceneObjectPart p in prims) | ||
7820 | parts.Add(p); | ||
7821 | foreach (ScenePresence p in avatars) | ||
7822 | parts.Add(p); | ||
7823 | |||
7824 | LSL_List remaining = null; | ||
7825 | uint rulesParsed = 0; | ||
7826 | |||
7827 | if (parts.Count > 0) | ||
7828 | { | ||
7829 | foreach (object part in parts) | ||
7830 | { | ||
7831 | if (part is SceneObjectPart) | ||
7832 | remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); | ||
7833 | else | ||
7834 | remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); | ||
7835 | } | ||
7836 | |||
7837 | while ((object)remaining != null && remaining.Length > 2) | ||
7838 | { | ||
7839 | linknumber = remaining.GetLSLIntegerItem(0); | ||
7840 | rules = remaining.GetSublist(1, -1); | ||
7841 | parts.Clear(); | ||
7842 | prims = GetLinkParts(linknumber); | ||
7843 | avatars = GetLinkAvatars(linknumber); | ||
7844 | foreach (SceneObjectPart p in prims) | ||
7845 | parts.Add(p); | ||
7846 | foreach (ScenePresence p in avatars) | ||
7847 | parts.Add(p); | ||
7848 | |||
7849 | remaining = null; | ||
7850 | foreach (object part in parts) | ||
7851 | { | ||
7852 | if (part is SceneObjectPart) | ||
7853 | remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); | ||
7854 | else | ||
7855 | remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); | ||
7856 | } | ||
7857 | } | ||
7858 | } | ||
7309 | } | 7859 | } |
7310 | 7860 | ||
7311 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7861 | private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, |
7862 | float material_density, float material_friction, | ||
7863 | float material_restitution, float material_gravity_modifier) | ||
7312 | { | 7864 | { |
7313 | m_host.AddScriptLPS(1); | 7865 | ExtraPhysicsData physdata = new ExtraPhysicsData(); |
7866 | physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType; | ||
7867 | physdata.Density = part.Density; | ||
7868 | physdata.Friction = part.Friction; | ||
7869 | physdata.Bounce = part.Bounciness; | ||
7870 | physdata.GravitationModifier = part.GravityModifier; | ||
7314 | 7871 | ||
7315 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); | 7872 | if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0) |
7873 | physdata.Density = material_density; | ||
7874 | if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0) | ||
7875 | physdata.Friction = material_friction; | ||
7876 | if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0) | ||
7877 | physdata.Bounce = material_restitution; | ||
7878 | if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0) | ||
7879 | physdata.GravitationModifier = material_gravity_modifier; | ||
7880 | |||
7881 | part.UpdateExtraPhysics(physdata); | ||
7316 | } | 7882 | } |
7317 | 7883 | ||
7318 | protected void setLinkPrimParams(int linknumber, LSL_List rules, string originFunc) | 7884 | public void llSetPhysicsMaterial(int material_bits, |
7885 | float material_gravity_modifier, float material_restitution, | ||
7886 | float material_friction, float material_density) | ||
7319 | { | 7887 | { |
7320 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7888 | SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); |
7889 | } | ||
7321 | 7890 | ||
7322 | LSL_List remaining = null; | 7891 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
7323 | uint rulesParsed = 0; | 7892 | { |
7893 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); | ||
7894 | llSetLinkPrimitiveParamsFast(linknumber, rules); | ||
7895 | ScriptSleep(200); | ||
7896 | } | ||
7324 | 7897 | ||
7325 | foreach (SceneObjectPart part in parts) | 7898 | // vector up using libomv (c&p from sop ) |
7326 | remaining = SetPrimParams(part, rules, originFunc, ref rulesParsed); | 7899 | // vector up rotated by r |
7900 | private Vector3 Zrot(Quaternion r) | ||
7901 | { | ||
7902 | double x, y, z, m; | ||
7327 | 7903 | ||
7328 | while (remaining != null && remaining.Length > 2) | 7904 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; |
7905 | if (Math.Abs(1.0 - m) > 0.000001) | ||
7329 | { | 7906 | { |
7330 | linknumber = remaining.GetLSLIntegerItem(0); | 7907 | m = 1.0 / Math.Sqrt(m); |
7331 | rules = remaining.GetSublist(1, -1); | 7908 | r.X *= (float)m; |
7332 | parts = GetLinkParts(linknumber); | 7909 | r.Y *= (float)m; |
7333 | 7910 | r.Z *= (float)m; | |
7334 | foreach (SceneObjectPart part in parts) | 7911 | r.W *= (float)m; |
7335 | remaining = SetPrimParams(part, rules, originFunc, ref rulesParsed); | ||
7336 | } | 7912 | } |
7913 | |||
7914 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
7915 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
7916 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
7917 | |||
7918 | return new Vector3((float)x, (float)y, (float)z); | ||
7337 | } | 7919 | } |
7338 | 7920 | ||
7339 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) | 7921 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) |
7340 | { | 7922 | { |
7923 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7924 | return null; | ||
7925 | |||
7341 | int idx = 0; | 7926 | int idx = 0; |
7342 | int idxStart = 0; | 7927 | int idxStart = 0; |
7343 | 7928 | ||
7929 | SceneObjectGroup parentgrp = part.ParentGroup; | ||
7930 | |||
7344 | bool positionChanged = false; | 7931 | bool positionChanged = false; |
7345 | LSL_Vector currentPosition = GetPartLocalPos(part); | 7932 | LSL_Vector currentPosition = GetPartLocalPos(part); |
7346 | 7933 | ||
@@ -7365,8 +7952,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7365 | return null; | 7952 | return null; |
7366 | 7953 | ||
7367 | v=rules.GetVector3Item(idx++); | 7954 | v=rules.GetVector3Item(idx++); |
7955 | if (part.IsRoot && !part.ParentGroup.IsAttachment) | ||
7956 | currentPosition = GetSetPosTarget(part, v, currentPosition, true); | ||
7957 | else | ||
7958 | currentPosition = GetSetPosTarget(part, v, currentPosition, false); | ||
7368 | positionChanged = true; | 7959 | positionChanged = true; |
7369 | currentPosition = GetSetPosTarget(part, v, currentPosition); | ||
7370 | 7960 | ||
7371 | break; | 7961 | break; |
7372 | case (int)ScriptBaseClass.PRIM_SIZE: | 7962 | case (int)ScriptBaseClass.PRIM_SIZE: |
@@ -7383,7 +7973,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7383 | 7973 | ||
7384 | LSL_Rotation q = rules.GetQuaternionItem(idx++); | 7974 | LSL_Rotation q = rules.GetQuaternionItem(idx++); |
7385 | // try to let this work as in SL... | 7975 | // try to let this work as in SL... |
7386 | if (part.ParentID == 0) | 7976 | if (part.ParentID == 0 || (part.ParentGroup != null && part == part.ParentGroup.RootPart)) |
7387 | { | 7977 | { |
7388 | // special case: If we are root, rotate complete SOG to new rotation | 7978 | // special case: If we are root, rotate complete SOG to new rotation |
7389 | SetRot(part, q); | 7979 | SetRot(part, q); |
@@ -7643,7 +8233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7643 | return null; | 8233 | return null; |
7644 | 8234 | ||
7645 | string ph = rules.Data[idx++].ToString(); | 8235 | string ph = rules.Data[idx++].ToString(); |
7646 | m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); | 8236 | parentgrp.ScriptSetPhantomStatus(ph.Equals("1")); |
7647 | 8237 | ||
7648 | break; | 8238 | break; |
7649 | 8239 | ||
@@ -7661,12 +8251,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7661 | part.ScriptSetPhysicsStatus(physics); | 8251 | part.ScriptSetPhysicsStatus(physics); |
7662 | break; | 8252 | break; |
7663 | 8253 | ||
8254 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
8255 | if (remain < 1) | ||
8256 | return null; | ||
8257 | |||
8258 | int shape_type = rules.GetLSLIntegerItem(idx++); | ||
8259 | |||
8260 | ExtraPhysicsData physdata = new ExtraPhysicsData(); | ||
8261 | physdata.Density = part.Density; | ||
8262 | physdata.Bounce = part.Bounciness; | ||
8263 | physdata.GravitationModifier = part.GravityModifier; | ||
8264 | physdata.PhysShapeType = (PhysShapeType)shape_type; | ||
8265 | |||
8266 | part.UpdateExtraPhysics(physdata); | ||
8267 | |||
8268 | break; | ||
8269 | |||
8270 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
8271 | if (remain < 5) | ||
8272 | return null; | ||
8273 | |||
8274 | int material_bits = rules.GetLSLIntegerItem(idx++); | ||
8275 | float material_density = (float)rules.GetLSLFloatItem(idx++); | ||
8276 | float material_friction = (float)rules.GetLSLFloatItem(idx++); | ||
8277 | float material_restitution = (float)rules.GetLSLFloatItem(idx++); | ||
8278 | float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++); | ||
8279 | |||
8280 | SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); | ||
8281 | |||
8282 | break; | ||
8283 | |||
7664 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | 8284 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: |
7665 | if (remain < 1) | 8285 | if (remain < 1) |
7666 | return null; | 8286 | return null; |
7667 | string temp = rules.Data[idx++].ToString(); | 8287 | string temp = rules.Data[idx++].ToString(); |
7668 | 8288 | ||
7669 | m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); | 8289 | parentgrp.ScriptSetTemporaryStatus(temp.Equals("1")); |
7670 | 8290 | ||
7671 | break; | 8291 | break; |
7672 | 8292 | ||
@@ -7740,14 +8360,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7740 | if (part.ParentGroup.RootPart == part) | 8360 | if (part.ParentGroup.RootPart == part) |
7741 | { | 8361 | { |
7742 | SceneObjectGroup parent = part.ParentGroup; | 8362 | SceneObjectGroup parent = part.ParentGroup; |
7743 | parent.UpdateGroupPosition(currentPosition); | 8363 | Util.FireAndForget(delegate(object x) { |
8364 | parent.UpdateGroupPosition(currentPosition); | ||
8365 | }); | ||
7744 | } | 8366 | } |
7745 | else | 8367 | else |
7746 | { | 8368 | { |
7747 | part.OffsetPosition = currentPosition; | 8369 | part.OffsetPosition = currentPosition; |
7748 | SceneObjectGroup parent = part.ParentGroup; | 8370 | // SceneObjectGroup parent = part.ParentGroup; |
7749 | parent.HasGroupChanged = true; | 8371 | // parent.HasGroupChanged = true; |
7750 | parent.ScheduleGroupForTerseUpdate(); | 8372 | // parent.ScheduleGroupForTerseUpdate(); |
8373 | part.ScheduleTerseUpdate(); | ||
7751 | } | 8374 | } |
7752 | } | 8375 | } |
7753 | } | 8376 | } |
@@ -7785,10 +8408,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7785 | 8408 | ||
7786 | public LSL_String llXorBase64Strings(string str1, string str2) | 8409 | public LSL_String llXorBase64Strings(string str1, string str2) |
7787 | { | 8410 | { |
7788 | m_host.AddScriptLPS(1); | 8411 | string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
7789 | Deprecated("llXorBase64Strings"); | 8412 | |
7790 | ScriptSleep(300); | 8413 | ScriptSleep(300); |
7791 | return String.Empty; | 8414 | m_host.AddScriptLPS(1); |
8415 | |||
8416 | if (str1 == String.Empty) | ||
8417 | return String.Empty; | ||
8418 | if (str2 == String.Empty) | ||
8419 | return str1; | ||
8420 | |||
8421 | int len = str2.Length; | ||
8422 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
8423 | { | ||
8424 | while (str2.EndsWith("=")) | ||
8425 | str2 = str2.Substring(0, str2.Length - 1); | ||
8426 | |||
8427 | len = str2.Length; | ||
8428 | int mod = len % 4; | ||
8429 | |||
8430 | if (mod == 1) | ||
8431 | str2 = str2.Substring(0, str2.Length - 1); | ||
8432 | else if (mod == 2) | ||
8433 | str2 += "=="; | ||
8434 | else if (mod == 3) | ||
8435 | str2 += "="; | ||
8436 | } | ||
8437 | |||
8438 | byte[] data1; | ||
8439 | byte[] data2; | ||
8440 | try | ||
8441 | { | ||
8442 | data1 = Convert.FromBase64String(str1); | ||
8443 | data2 = Convert.FromBase64String(str2); | ||
8444 | } | ||
8445 | catch (Exception) | ||
8446 | { | ||
8447 | return new LSL_String(String.Empty); | ||
8448 | } | ||
8449 | |||
8450 | // For cases where the decoded length of s2 is greater | ||
8451 | // than the decoded length of s1, simply perform a normal | ||
8452 | // decode and XOR | ||
8453 | // | ||
8454 | if (data2.Length >= data1.Length) | ||
8455 | { | ||
8456 | for (int pos = 0 ; pos < data1.Length ; pos++ ) | ||
8457 | data1[pos] ^= data2[pos]; | ||
8458 | |||
8459 | return Convert.ToBase64String(data1); | ||
8460 | } | ||
8461 | |||
8462 | // Remove padding | ||
8463 | while (str1.EndsWith("=")) | ||
8464 | str1 = str1.Substring(0, str1.Length - 1); | ||
8465 | while (str2.EndsWith("=")) | ||
8466 | str2 = str2.Substring(0, str2.Length - 1); | ||
8467 | |||
8468 | byte[] d1 = new byte[str1.Length]; | ||
8469 | byte[] d2 = new byte[str2.Length]; | ||
8470 | |||
8471 | for (int i = 0 ; i < str1.Length ; i++) | ||
8472 | { | ||
8473 | int idx = b64.IndexOf(str1.Substring(i, 1)); | ||
8474 | if (idx == -1) | ||
8475 | idx = 0; | ||
8476 | d1[i] = (byte)idx; | ||
8477 | } | ||
8478 | |||
8479 | for (int i = 0 ; i < str2.Length ; i++) | ||
8480 | { | ||
8481 | int idx = b64.IndexOf(str2.Substring(i, 1)); | ||
8482 | if (idx == -1) | ||
8483 | idx = 0; | ||
8484 | d2[i] = (byte)idx; | ||
8485 | } | ||
8486 | |||
8487 | string output = String.Empty; | ||
8488 | |||
8489 | for (int pos = 0 ; pos < d1.Length ; pos++) | ||
8490 | output += b64[d1[pos] ^ d2[pos % d2.Length]]; | ||
8491 | |||
8492 | while (output.Length % 3 > 0) | ||
8493 | output += "="; | ||
8494 | |||
8495 | return output; | ||
7792 | } | 8496 | } |
7793 | 8497 | ||
7794 | public void llRemoteDataSetRegion() | 8498 | public void llRemoteDataSetRegion() |
@@ -7912,8 +8616,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7912 | public LSL_Integer llGetNumberOfPrims() | 8616 | public LSL_Integer llGetNumberOfPrims() |
7913 | { | 8617 | { |
7914 | m_host.AddScriptLPS(1); | 8618 | m_host.AddScriptLPS(1); |
7915 | 8619 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; | |
7916 | return m_host.ParentGroup.PrimCount + m_host.ParentGroup.GetSittingAvatarsCount(); | 8620 | |
8621 | return m_host.ParentGroup.PrimCount + avatarCount; | ||
7917 | } | 8622 | } |
7918 | 8623 | ||
7919 | /// <summary> | 8624 | /// <summary> |
@@ -7928,55 +8633,114 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7928 | m_host.AddScriptLPS(1); | 8633 | m_host.AddScriptLPS(1); |
7929 | UUID objID = UUID.Zero; | 8634 | UUID objID = UUID.Zero; |
7930 | LSL_List result = new LSL_List(); | 8635 | LSL_List result = new LSL_List(); |
8636 | |||
8637 | // If the ID is not valid, return null result | ||
7931 | if (!UUID.TryParse(obj, out objID)) | 8638 | if (!UUID.TryParse(obj, out objID)) |
7932 | { | 8639 | { |
7933 | result.Add(new LSL_Vector()); | 8640 | result.Add(new LSL_Vector()); |
7934 | result.Add(new LSL_Vector()); | 8641 | result.Add(new LSL_Vector()); |
7935 | return result; | 8642 | return result; |
7936 | } | 8643 | } |
8644 | |||
8645 | // Check if this is an attached prim. If so, replace | ||
8646 | // the UUID with the avatar UUID and report it's bounding box | ||
8647 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
8648 | if (part != null && part.ParentGroup.IsAttachment) | ||
8649 | objID = part.ParentGroup.AttachedAvatar; | ||
8650 | |||
8651 | // Find out if this is an avatar ID. If so, return it's box | ||
7937 | ScenePresence presence = World.GetScenePresence(objID); | 8652 | ScenePresence presence = World.GetScenePresence(objID); |
7938 | if (presence != null) | 8653 | if (presence != null) |
7939 | { | 8654 | { |
7940 | if (presence.ParentID == 0) // not sat on an object | 8655 | // As per LSL Wiki, there is no difference between sitting |
8656 | // and standing avatar since server 1.36 | ||
8657 | LSL_Vector lower; | ||
8658 | LSL_Vector upper; | ||
8659 | |||
8660 | Vector3 box = presence.Appearance.AvatarBoxSize * 0.5f; | ||
8661 | |||
8662 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID | ||
8663 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
8664 | /* | ||
7941 | { | 8665 | { |
7942 | LSL_Vector lower; | 8666 | // This is for ground sitting avatars |
7943 | LSL_Vector upper; | 8667 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7944 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID | 8668 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7945 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 8669 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7946 | { | 8670 | } |
7947 | // This is for ground sitting avatars | 8671 | else |
7948 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | 8672 | { |
7949 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | 8673 | // This is for standing/flying avatars |
7950 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | 8674 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7951 | } | 8675 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7952 | else | 8676 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7953 | { | 8677 | } |
7954 | // This is for standing/flying avatars | 8678 | |
7955 | float height = presence.Appearance.AvatarHeight / 2.0f; | 8679 | // Adjust to the documented error offsets (see LSL Wiki) |
7956 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | 8680 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); |
7957 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | 8681 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); |
7958 | } | 8682 | */ |
7959 | result.Add(lower); | 8683 | { |
7960 | result.Add(upper); | 8684 | // This is for ground sitting avatars TODO! |
7961 | return result; | 8685 | lower = new LSL_Vector(-box.X - 0.1125, -box.Y, box.Z * -1.0f); |
8686 | upper = new LSL_Vector(box.X + 0.1125, box.Y, box.Z * -1.0f); | ||
7962 | } | 8687 | } |
7963 | else | 8688 | else |
7964 | { | 8689 | { |
7965 | // sitting on an object so we need the bounding box of that | 8690 | // This is for standing/flying avatars |
7966 | // which should include the avatar so set the UUID to the | 8691 | lower = new LSL_Vector(-box.X, -box.Y, -box.Z); |
7967 | // UUID of the object the avatar is sat on and allow it to fall through | 8692 | upper = new LSL_Vector(box.X, box.Y, box.Z); |
7968 | // to processing an object | ||
7969 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7970 | objID = p.UUID; | ||
7971 | } | 8693 | } |
8694 | |||
8695 | if (lower.x > upper.x) | ||
8696 | lower.x = upper.x; | ||
8697 | if (lower.y > upper.y) | ||
8698 | lower.y = upper.y; | ||
8699 | if (lower.z > upper.z) | ||
8700 | lower.z = upper.z; | ||
8701 | |||
8702 | result.Add(lower); | ||
8703 | result.Add(upper); | ||
8704 | return result; | ||
7972 | } | 8705 | } |
7973 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 8706 | |
8707 | part = World.GetSceneObjectPart(objID); | ||
7974 | // Currently only works for single prims without a sitting avatar | 8708 | // Currently only works for single prims without a sitting avatar |
7975 | if (part != null) | 8709 | if (part != null) |
7976 | { | 8710 | { |
7977 | Vector3 halfSize = part.Scale / 2.0f; | 8711 | float minX; |
7978 | LSL_Vector lower = (new LSL_Vector(halfSize)) * -1.0f; | 8712 | float maxX; |
7979 | LSL_Vector upper = new LSL_Vector(halfSize); | 8713 | float minY; |
8714 | float maxY; | ||
8715 | float minZ; | ||
8716 | float maxZ; | ||
8717 | |||
8718 | // This BBox is in sim coordinates, with the offset being | ||
8719 | // a contained point. | ||
8720 | Vector3[] offsets = Scene.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
8721 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
8722 | |||
8723 | minX -= offsets[0].X; | ||
8724 | maxX -= offsets[0].X; | ||
8725 | minY -= offsets[0].Y; | ||
8726 | maxY -= offsets[0].Y; | ||
8727 | minZ -= offsets[0].Z; | ||
8728 | maxZ -= offsets[0].Z; | ||
8729 | |||
8730 | LSL_Vector lower; | ||
8731 | LSL_Vector upper; | ||
8732 | |||
8733 | // Adjust to the documented error offsets (see LSL Wiki) | ||
8734 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
8735 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
8736 | |||
8737 | if (lower.x > upper.x) | ||
8738 | lower.x = upper.x; | ||
8739 | if (lower.y > upper.y) | ||
8740 | lower.y = upper.y; | ||
8741 | if (lower.z > upper.z) | ||
8742 | lower.z = upper.z; | ||
8743 | |||
7980 | result.Add(lower); | 8744 | result.Add(lower); |
7981 | result.Add(upper); | 8745 | result.Add(upper); |
7982 | return result; | 8746 | return result; |
@@ -7990,7 +8754,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7990 | 8754 | ||
7991 | public LSL_Vector llGetGeometricCenter() | 8755 | public LSL_Vector llGetGeometricCenter() |
7992 | { | 8756 | { |
7993 | return new LSL_Vector(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z); | 8757 | Vector3 tmp = m_host.GetGeometricCenter(); |
8758 | return new LSL_Vector(tmp.X, tmp.Y, tmp.Z); | ||
7994 | } | 8759 | } |
7995 | 8760 | ||
7996 | public LSL_List llGetPrimitiveParams(LSL_List rules) | 8761 | public LSL_List llGetPrimitiveParams(LSL_List rules) |
@@ -8001,7 +8766,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8001 | 8766 | ||
8002 | LSL_List remaining = GetPrimParams(m_host, rules, ref result); | 8767 | LSL_List remaining = GetPrimParams(m_host, rules, ref result); |
8003 | 8768 | ||
8004 | while (remaining != null && remaining.Length > 2) | 8769 | while ((object)remaining != null && remaining.Length > 2) |
8005 | { | 8770 | { |
8006 | int linknumber = remaining.GetLSLIntegerItem(0); | 8771 | int linknumber = remaining.GetLSLIntegerItem(0); |
8007 | rules = remaining.GetSublist(1, -1); | 8772 | rules = remaining.GetSublist(1, -1); |
@@ -8018,24 +8783,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8018 | { | 8783 | { |
8019 | m_host.AddScriptLPS(1); | 8784 | m_host.AddScriptLPS(1); |
8020 | 8785 | ||
8021 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 8786 | // acording to SL wiki this must indicate a single link number or link_root or link_this. |
8787 | // keep other options as before | ||
8022 | 8788 | ||
8789 | List<SceneObjectPart> parts; | ||
8790 | List<ScenePresence> avatars; | ||
8791 | |||
8023 | LSL_List res = new LSL_List(); | 8792 | LSL_List res = new LSL_List(); |
8024 | LSL_List remaining = null; | 8793 | LSL_List remaining = null; |
8025 | 8794 | ||
8026 | foreach (SceneObjectPart part in parts) | 8795 | while (rules.Length > 0) |
8027 | { | ||
8028 | remaining = GetPrimParams(part, rules, ref res); | ||
8029 | } | ||
8030 | |||
8031 | while (remaining != null && remaining.Length > 2) | ||
8032 | { | 8796 | { |
8033 | linknumber = remaining.GetLSLIntegerItem(0); | ||
8034 | rules = remaining.GetSublist(1, -1); | ||
8035 | parts = GetLinkParts(linknumber); | 8797 | parts = GetLinkParts(linknumber); |
8798 | avatars = GetLinkAvatars(linknumber); | ||
8036 | 8799 | ||
8800 | remaining = null; | ||
8037 | foreach (SceneObjectPart part in parts) | 8801 | foreach (SceneObjectPart part in parts) |
8802 | { | ||
8038 | remaining = GetPrimParams(part, rules, ref res); | 8803 | remaining = GetPrimParams(part, rules, ref res); |
8804 | } | ||
8805 | foreach (ScenePresence avatar in avatars) | ||
8806 | { | ||
8807 | remaining = GetPrimParams(avatar, rules, ref res); | ||
8808 | } | ||
8809 | |||
8810 | if ((object)remaining != null && remaining.Length > 0) | ||
8811 | { | ||
8812 | linknumber = remaining.GetLSLIntegerItem(0); | ||
8813 | rules = remaining.GetSublist(1, -1); | ||
8814 | } | ||
8815 | else | ||
8816 | break; | ||
8039 | } | 8817 | } |
8040 | 8818 | ||
8041 | return res; | 8819 | return res; |
@@ -8080,13 +8858,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8080 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, | 8858 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, |
8081 | part.AbsolutePosition.Y, | 8859 | part.AbsolutePosition.Y, |
8082 | part.AbsolutePosition.Z); | 8860 | part.AbsolutePosition.Z); |
8083 | // For some reason, the part.AbsolutePosition.* values do not change if the | ||
8084 | // linkset is rotated; they always reflect the child prim's world position | ||
8085 | // as though the linkset is unrotated. This is incompatible behavior with SL's | ||
8086 | // implementation, so will break scripts imported from there (not to mention it | ||
8087 | // makes it more difficult to determine a child prim's actual inworld position). | ||
8088 | if (part.ParentID != 0) | ||
8089 | v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition(); | ||
8090 | res.Add(v); | 8861 | res.Add(v); |
8091 | break; | 8862 | break; |
8092 | 8863 | ||
@@ -8258,30 +9029,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8258 | if (remain < 1) | 9029 | if (remain < 1) |
8259 | return null; | 9030 | return null; |
8260 | 9031 | ||
8261 | face=(int)rules.GetLSLIntegerItem(idx++); | 9032 | face = (int)rules.GetLSLIntegerItem(idx++); |
8262 | 9033 | ||
8263 | tex = part.Shape.Textures; | 9034 | tex = part.Shape.Textures; |
9035 | int shiny; | ||
8264 | if (face == ScriptBaseClass.ALL_SIDES) | 9036 | if (face == ScriptBaseClass.ALL_SIDES) |
8265 | { | 9037 | { |
8266 | for (face = 0; face < GetNumberOfSides(part); face++) | 9038 | for (face = 0; face < GetNumberOfSides(part); face++) |
8267 | { | 9039 | { |
8268 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9040 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
8269 | // Convert Shininess to PRIM_SHINY_* | 9041 | if (shinyness == Shininess.High) |
8270 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 9042 | { |
8271 | // PRIM_BUMP_* | 9043 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
8272 | res.Add(new LSL_Integer((int)texface.Bump)); | 9044 | } |
9045 | else if (shinyness == Shininess.Medium) | ||
9046 | { | ||
9047 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
9048 | } | ||
9049 | else if (shinyness == Shininess.Low) | ||
9050 | { | ||
9051 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
9052 | } | ||
9053 | else | ||
9054 | { | ||
9055 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
9056 | } | ||
9057 | res.Add(new LSL_Integer(shiny)); | ||
9058 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8273 | } | 9059 | } |
8274 | } | 9060 | } |
8275 | else | 9061 | else |
8276 | { | 9062 | { |
8277 | if (face >= 0 && face < GetNumberOfSides(part)) | 9063 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
9064 | if (shinyness == Shininess.High) | ||
8278 | { | 9065 | { |
8279 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9066 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
8280 | // Convert Shininess to PRIM_SHINY_* | ||
8281 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | ||
8282 | // PRIM_BUMP_* | ||
8283 | res.Add(new LSL_Integer((int)texface.Bump)); | ||
8284 | } | 9067 | } |
9068 | else if (shinyness == Shininess.Medium) | ||
9069 | { | ||
9070 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
9071 | } | ||
9072 | else if (shinyness == Shininess.Low) | ||
9073 | { | ||
9074 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
9075 | } | ||
9076 | else | ||
9077 | { | ||
9078 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
9079 | } | ||
9080 | res.Add(new LSL_Integer(shiny)); | ||
9081 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8285 | } | 9082 | } |
8286 | break; | 9083 | break; |
8287 | 9084 | ||
@@ -8289,24 +9086,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8289 | if (remain < 1) | 9086 | if (remain < 1) |
8290 | return null; | 9087 | return null; |
8291 | 9088 | ||
8292 | face=(int)rules.GetLSLIntegerItem(idx++); | 9089 | face = (int)rules.GetLSLIntegerItem(idx++); |
8293 | 9090 | ||
8294 | tex = part.Shape.Textures; | 9091 | tex = part.Shape.Textures; |
9092 | int fullbright; | ||
8295 | if (face == ScriptBaseClass.ALL_SIDES) | 9093 | if (face == ScriptBaseClass.ALL_SIDES) |
8296 | { | 9094 | { |
8297 | for (face = 0; face < GetNumberOfSides(part); face++) | 9095 | for (face = 0; face < GetNumberOfSides(part); face++) |
8298 | { | 9096 | { |
8299 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9097 | if (tex.GetFace((uint)face).Fullbright == true) |
8300 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 9098 | { |
9099 | fullbright = ScriptBaseClass.TRUE; | ||
9100 | } | ||
9101 | else | ||
9102 | { | ||
9103 | fullbright = ScriptBaseClass.FALSE; | ||
9104 | } | ||
9105 | res.Add(new LSL_Integer(fullbright)); | ||
8301 | } | 9106 | } |
8302 | } | 9107 | } |
8303 | else | 9108 | else |
8304 | { | 9109 | { |
8305 | if (face >= 0 && face < GetNumberOfSides(part)) | 9110 | if (tex.GetFace((uint)face).Fullbright == true) |
8306 | { | 9111 | { |
8307 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9112 | fullbright = ScriptBaseClass.TRUE; |
8308 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 9113 | } |
9114 | else | ||
9115 | { | ||
9116 | fullbright = ScriptBaseClass.FALSE; | ||
8309 | } | 9117 | } |
9118 | res.Add(new LSL_Integer(fullbright)); | ||
8310 | } | 9119 | } |
8311 | break; | 9120 | break; |
8312 | 9121 | ||
@@ -8328,27 +9137,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8328 | break; | 9137 | break; |
8329 | 9138 | ||
8330 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 9139 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
9140 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
8331 | if (remain < 1) | 9141 | if (remain < 1) |
8332 | return null; | 9142 | return null; |
8333 | 9143 | ||
8334 | face=(int)rules.GetLSLIntegerItem(idx++); | 9144 | face = (int)rules.GetLSLIntegerItem(idx++); |
8335 | 9145 | ||
8336 | tex = part.Shape.Textures; | 9146 | tex = part.Shape.Textures; |
8337 | if (face == ScriptBaseClass.ALL_SIDES) | 9147 | if (face == ScriptBaseClass.ALL_SIDES) |
8338 | { | 9148 | { |
8339 | for (face = 0; face < GetNumberOfSides(part); face++) | 9149 | for (face = 0; face < GetNumberOfSides(part); face++) |
8340 | { | 9150 | { |
8341 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 9151 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
8342 | // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. | 9152 | { |
8343 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 9153 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
9154 | } | ||
9155 | else | ||
9156 | { | ||
9157 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
9158 | } | ||
8344 | } | 9159 | } |
8345 | } | 9160 | } |
8346 | else | 9161 | else |
8347 | { | 9162 | { |
8348 | if (face >= 0 && face < GetNumberOfSides(part)) | 9163 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
8349 | { | 9164 | { |
8350 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 9165 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
8351 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 9166 | } |
9167 | else | ||
9168 | { | ||
9169 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8352 | } | 9170 | } |
8353 | } | 9171 | } |
8354 | break; | 9172 | break; |
@@ -8372,24 +9190,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8372 | if (remain < 1) | 9190 | if (remain < 1) |
8373 | return null; | 9191 | return null; |
8374 | 9192 | ||
8375 | face=(int)rules.GetLSLIntegerItem(idx++); | 9193 | face = (int)rules.GetLSLIntegerItem(idx++); |
8376 | 9194 | ||
8377 | tex = part.Shape.Textures; | 9195 | tex = part.Shape.Textures; |
9196 | float primglow; | ||
8378 | if (face == ScriptBaseClass.ALL_SIDES) | 9197 | if (face == ScriptBaseClass.ALL_SIDES) |
8379 | { | 9198 | { |
8380 | for (face = 0; face < GetNumberOfSides(part); face++) | 9199 | for (face = 0; face < GetNumberOfSides(part); face++) |
8381 | { | 9200 | { |
8382 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 9201 | primglow = tex.GetFace((uint)face).Glow; |
8383 | res.Add(new LSL_Float(texface.Glow)); | 9202 | res.Add(new LSL_Float(primglow)); |
8384 | } | 9203 | } |
8385 | } | 9204 | } |
8386 | else | 9205 | else |
8387 | { | 9206 | { |
8388 | if (face >= 0 && face < GetNumberOfSides(part)) | 9207 | primglow = tex.GetFace((uint)face).Glow; |
8389 | { | 9208 | res.Add(new LSL_Float(primglow)); |
8390 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
8391 | res.Add(new LSL_Float(texface.Glow)); | ||
8392 | } | ||
8393 | } | 9209 | } |
8394 | break; | 9210 | break; |
8395 | 9211 | ||
@@ -8401,15 +9217,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8401 | textColor.B)); | 9217 | textColor.B)); |
8402 | res.Add(new LSL_Float(textColor.A)); | 9218 | res.Add(new LSL_Float(textColor.A)); |
8403 | break; | 9219 | break; |
9220 | |||
8404 | case (int)ScriptBaseClass.PRIM_NAME: | 9221 | case (int)ScriptBaseClass.PRIM_NAME: |
8405 | res.Add(new LSL_String(part.Name)); | 9222 | res.Add(new LSL_String(part.Name)); |
8406 | break; | 9223 | break; |
9224 | |||
8407 | case (int)ScriptBaseClass.PRIM_DESC: | 9225 | case (int)ScriptBaseClass.PRIM_DESC: |
8408 | res.Add(new LSL_String(part.Description)); | 9226 | res.Add(new LSL_String(part.Description)); |
8409 | break; | 9227 | break; |
9228 | |||
8410 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 9229 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
8411 | res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); | 9230 | res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); |
8412 | break; | 9231 | break; |
9232 | |||
8413 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 9233 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
8414 | res.Add(new LSL_Vector(GetPartLocalPos(part))); | 9234 | res.Add(new LSL_Vector(GetPartLocalPos(part))); |
8415 | break; | 9235 | break; |
@@ -9020,8 +9840,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9020 | // The function returns an ordered list | 9840 | // The function returns an ordered list |
9021 | // representing the tokens found in the supplied | 9841 | // representing the tokens found in the supplied |
9022 | // sources string. If two successive tokenizers | 9842 | // sources string. If two successive tokenizers |
9023 | // are encountered, then a NULL entry is added | 9843 | // are encountered, then a null-string entry is |
9024 | // to the list. | 9844 | // added to the list. |
9025 | // | 9845 | // |
9026 | // It is a precondition that the source and | 9846 | // It is a precondition that the source and |
9027 | // toekizer lisst are non-null. If they are null, | 9847 | // toekizer lisst are non-null. If they are null, |
@@ -9029,7 +9849,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9029 | // while their lengths are being determined. | 9849 | // while their lengths are being determined. |
9030 | // | 9850 | // |
9031 | // A small amount of working memoryis required | 9851 | // A small amount of working memoryis required |
9032 | // of approximately 8*#tokenizers. | 9852 | // of approximately 8*#tokenizers + 8*srcstrlen. |
9033 | // | 9853 | // |
9034 | // There are many ways in which this function | 9854 | // There are many ways in which this function |
9035 | // can be implemented, this implementation is | 9855 | // can be implemented, this implementation is |
@@ -9045,155 +9865,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9045 | // and eliminates redundant tokenizers as soon | 9865 | // and eliminates redundant tokenizers as soon |
9046 | // as is possible. | 9866 | // as is possible. |
9047 | // | 9867 | // |
9048 | // The implementation tries to avoid any copying | 9868 | // The implementation tries to minimize temporary |
9049 | // of arrays or other objects. | 9869 | // garbage generation. |
9050 | // </remarks> | 9870 | // </remarks> |
9051 | 9871 | ||
9052 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 9872 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
9053 | { | 9873 | { |
9054 | int beginning = 0; | 9874 | return ParseString2List(src, separators, spacers, true); |
9055 | int srclen = src.Length; | 9875 | } |
9056 | int seplen = separators.Length; | ||
9057 | object[] separray = separators.Data; | ||
9058 | int spclen = spacers.Length; | ||
9059 | object[] spcarray = spacers.Data; | ||
9060 | int mlen = seplen+spclen; | ||
9061 | |||
9062 | int[] offset = new int[mlen+1]; | ||
9063 | bool[] active = new bool[mlen]; | ||
9064 | |||
9065 | int best; | ||
9066 | int j; | ||
9067 | |||
9068 | // Initial capacity reduces resize cost | ||
9069 | 9876 | ||
9070 | LSL_List tokens = new LSL_List(); | 9877 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
9878 | { | ||
9879 | int srclen = src.Length; | ||
9880 | int seplen = separators.Length; | ||
9881 | object[] separray = separators.Data; | ||
9882 | int spclen = spacers.Length; | ||
9883 | object[] spcarray = spacers.Data; | ||
9884 | int dellen = 0; | ||
9885 | string[] delarray = new string[seplen+spclen]; | ||
9071 | 9886 | ||
9072 | // All entries are initially valid | 9887 | int outlen = 0; |
9888 | string[] outarray = new string[srclen*2+1]; | ||
9073 | 9889 | ||
9074 | for (int i = 0; i < mlen; i++) | 9890 | int i, j; |
9075 | active[i] = true; | 9891 | string d; |
9076 | 9892 | ||
9077 | offset[mlen] = srclen; | 9893 | m_host.AddScriptLPS(1); |
9078 | 9894 | ||
9079 | while (beginning < srclen) | 9895 | /* |
9896 | * Convert separator and spacer lists to C# strings. | ||
9897 | * Also filter out null strings so we don't hang. | ||
9898 | */ | ||
9899 | for (i = 0; i < seplen; i ++) | ||
9080 | { | 9900 | { |
9901 | d = separray[i].ToString(); | ||
9902 | if (d.Length > 0) | ||
9903 | { | ||
9904 | delarray[dellen++] = d; | ||
9905 | } | ||
9906 | } | ||
9907 | seplen = dellen; | ||
9081 | 9908 | ||
9082 | best = mlen; // as bad as it gets | 9909 | for (i = 0; i < spclen; i ++) |
9910 | { | ||
9911 | d = spcarray[i].ToString(); | ||
9912 | if (d.Length > 0) | ||
9913 | { | ||
9914 | delarray[dellen++] = d; | ||
9915 | } | ||
9916 | } | ||
9083 | 9917 | ||
9084 | // Scan for separators | 9918 | /* |
9919 | * Scan through source string from beginning to end. | ||
9920 | */ | ||
9921 | for (i = 0;;) | ||
9922 | { | ||
9085 | 9923 | ||
9086 | for (j = 0; j < seplen; j++) | 9924 | /* |
9925 | * Find earliest delimeter in src starting at i (if any). | ||
9926 | */ | ||
9927 | int earliestDel = -1; | ||
9928 | int earliestSrc = srclen; | ||
9929 | string earliestStr = null; | ||
9930 | for (j = 0; j < dellen; j ++) | ||
9087 | { | 9931 | { |
9088 | if (separray[j].ToString() == String.Empty) | 9932 | d = delarray[j]; |
9089 | active[j] = false; | 9933 | if (d != null) |
9090 | |||
9091 | if (active[j]) | ||
9092 | { | 9934 | { |
9093 | // scan all of the markers | 9935 | int index = src.IndexOf(d, i); |
9094 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 9936 | if (index < 0) |
9095 | { | 9937 | { |
9096 | // not present at all | 9938 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
9097 | active[j] = false; | ||
9098 | } | 9939 | } |
9099 | else | 9940 | else if (index < earliestSrc) |
9100 | { | 9941 | { |
9101 | // present and correct | 9942 | earliestSrc = index; // where delimeter starts in source string |
9102 | if (offset[j] < offset[best]) | 9943 | earliestDel = j; // where delimeter is in delarray[] |
9103 | { | 9944 | earliestStr = d; // the delimeter string from delarray[] |
9104 | // closest so far | 9945 | if (index == i) break; // can't do any better than found at beg of string |
9105 | best = j; | ||
9106 | if (offset[best] == beginning) | ||
9107 | break; | ||
9108 | } | ||
9109 | } | 9946 | } |
9110 | } | 9947 | } |
9111 | } | 9948 | } |
9112 | 9949 | ||
9113 | // Scan for spacers | 9950 | /* |
9114 | 9951 | * Output source string starting at i through start of earliest delimeter. | |
9115 | if (offset[best] != beginning) | 9952 | */ |
9953 | if (keepNulls || (earliestSrc > i)) | ||
9116 | { | 9954 | { |
9117 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 9955 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
9118 | { | ||
9119 | if (spcarray[j-seplen].ToString() == String.Empty) | ||
9120 | active[j] = false; | ||
9121 | |||
9122 | if (active[j]) | ||
9123 | { | ||
9124 | // scan all of the markers | ||
9125 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | ||
9126 | { | ||
9127 | // not present at all | ||
9128 | active[j] = false; | ||
9129 | } | ||
9130 | else | ||
9131 | { | ||
9132 | // present and correct | ||
9133 | if (offset[j] < offset[best]) | ||
9134 | { | ||
9135 | // closest so far | ||
9136 | best = j; | ||
9137 | } | ||
9138 | } | ||
9139 | } | ||
9140 | } | ||
9141 | } | 9956 | } |
9142 | 9957 | ||
9143 | // This is the normal exit from the scanning loop | 9958 | /* |
9959 | * If no delimeter found at or after i, we're done scanning. | ||
9960 | */ | ||
9961 | if (earliestDel < 0) break; | ||
9144 | 9962 | ||
9145 | if (best == mlen) | 9963 | /* |
9964 | * If delimeter was a spacer, output the spacer. | ||
9965 | */ | ||
9966 | if (earliestDel >= seplen) | ||
9146 | { | 9967 | { |
9147 | // no markers were found on this pass | 9968 | outarray[outlen++] = earliestStr; |
9148 | // so we're pretty much done | ||
9149 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
9150 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
9151 | break; | ||
9152 | } | 9969 | } |
9153 | 9970 | ||
9154 | // Otherwise we just add the newly delimited token | 9971 | /* |
9155 | // and recalculate where the search should continue. | 9972 | * Look at rest of src string following delimeter. |
9156 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 9973 | */ |
9157 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 9974 | i = earliestSrc + earliestStr.Length; |
9158 | |||
9159 | if (best < seplen) | ||
9160 | { | ||
9161 | beginning = offset[best] + (separray[best].ToString()).Length; | ||
9162 | } | ||
9163 | else | ||
9164 | { | ||
9165 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
9166 | string str = spcarray[best - seplen].ToString(); | ||
9167 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
9168 | tokens.Add(new LSL_String(str)); | ||
9169 | } | ||
9170 | } | 9975 | } |
9171 | 9976 | ||
9172 | // This an awkward an not very intuitive boundary case. If the | 9977 | /* |
9173 | // last substring is a tokenizer, then there is an implied trailing | 9978 | * Make up an exact-sized output array suitable for an LSL_List object. |
9174 | // null list entry. Hopefully the single comparison will not be too | 9979 | */ |
9175 | // arduous. Alternatively the 'break' could be replced with a return | 9980 | object[] outlist = new object[outlen]; |
9176 | // but that's shabby programming. | 9981 | for (i = 0; i < outlen; i ++) |
9177 | |||
9178 | if ((beginning == srclen) && (keepNulls)) | ||
9179 | { | 9982 | { |
9180 | if (srclen != 0) | 9983 | outlist[i] = new LSL_String(outarray[i]); |
9181 | tokens.Add(new LSL_String("")); | ||
9182 | } | 9984 | } |
9183 | 9985 | return new LSL_List(outlist); | |
9184 | return tokens; | ||
9185 | } | ||
9186 | |||
9187 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
9188 | { | ||
9189 | m_host.AddScriptLPS(1); | ||
9190 | return this.ParseString(src, separators, spacers, false); | ||
9191 | } | ||
9192 | |||
9193 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
9194 | { | ||
9195 | m_host.AddScriptLPS(1); | ||
9196 | return this.ParseString(src, separators, spacers, true); | ||
9197 | } | 9986 | } |
9198 | 9987 | ||
9199 | public LSL_Integer llGetObjectPermMask(int mask) | 9988 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -9288,6 +10077,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9288 | case 4: | 10077 | case 4: |
9289 | return (int)item.NextPermissions; | 10078 | return (int)item.NextPermissions; |
9290 | } | 10079 | } |
10080 | m_host.TaskInventory.LockItemsForRead(false); | ||
9291 | 10081 | ||
9292 | return -1; | 10082 | return -1; |
9293 | } | 10083 | } |
@@ -9490,31 +10280,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9490 | UUID key = new UUID(); | 10280 | UUID key = new UUID(); |
9491 | if (UUID.TryParse(id, out key)) | 10281 | if (UUID.TryParse(id, out key)) |
9492 | { | 10282 | { |
9493 | try | 10283 | // return total object mass |
9494 | { | 10284 | SceneObjectPart part = World.GetSceneObjectPart(key); |
9495 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); | 10285 | if (part != null) |
9496 | if (obj != null) | 10286 | return part.ParentGroup.GetMass(); |
9497 | return (double)obj.GetMass(); | 10287 | |
9498 | // the object is null so the key is for an avatar | 10288 | // the object is null so the key is for an avatar |
9499 | ScenePresence avatar = World.GetScenePresence(key); | 10289 | ScenePresence avatar = World.GetScenePresence(key); |
9500 | if (avatar != null) | 10290 | if (avatar != null) |
9501 | if (avatar.IsChildAgent) | ||
9502 | // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass | ||
9503 | // child agents have a mass of 1.0 | ||
9504 | return 1; | ||
9505 | else | ||
9506 | return (double)avatar.GetMass(); | ||
9507 | } | ||
9508 | catch (KeyNotFoundException) | ||
9509 | { | 10291 | { |
9510 | return 0; // The Object/Agent not in the region so just return zero | 10292 | if (avatar.IsChildAgent) |
10293 | { | ||
10294 | // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass | ||
10295 | // child agents have a mass of 1.0 | ||
10296 | return 1; | ||
10297 | } | ||
10298 | else | ||
10299 | { | ||
10300 | return (double)avatar.GetMass(); | ||
10301 | } | ||
9511 | } | 10302 | } |
9512 | } | 10303 | } |
9513 | return 0; | 10304 | return 0; |
9514 | } | 10305 | } |
9515 | 10306 | ||
9516 | /// <summary> | 10307 | /// <summary> |
9517 | /// illListReplaceList removes the sub-list defined by the inclusive indices | 10308 | /// llListReplaceList removes the sub-list defined by the inclusive indices |
9518 | /// start and end and inserts the src list in its place. The inclusive | 10309 | /// start and end and inserts the src list in its place. The inclusive |
9519 | /// nature of the indices means that at least one element must be deleted | 10310 | /// nature of the indices means that at least one element must be deleted |
9520 | /// if the indices are within the bounds of the existing list. I.e. 2,2 | 10311 | /// if the indices are within the bounds of the existing list. I.e. 2,2 |
@@ -9571,16 +10362,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9571 | // based upon end. Note that if end exceeds the upper | 10362 | // based upon end. Note that if end exceeds the upper |
9572 | // bound in this case, the entire destination list | 10363 | // bound in this case, the entire destination list |
9573 | // is removed. | 10364 | // is removed. |
9574 | else | 10365 | else if (start == 0) |
9575 | { | 10366 | { |
9576 | if (end + 1 < dest.Length) | 10367 | if (end + 1 < dest.Length) |
9577 | { | ||
9578 | return src + dest.GetSublist(end + 1, -1); | 10368 | return src + dest.GetSublist(end + 1, -1); |
9579 | } | ||
9580 | else | 10369 | else |
9581 | { | ||
9582 | return src; | 10370 | return src; |
9583 | } | 10371 | } |
10372 | else // Start < 0 | ||
10373 | { | ||
10374 | if (end + 1 < dest.Length) | ||
10375 | return dest.GetSublist(end + 1, -1); | ||
10376 | else | ||
10377 | return new LSL_List(); | ||
9584 | } | 10378 | } |
9585 | } | 10379 | } |
9586 | // Finally, if start > end, we strip away a prefix and | 10380 | // Finally, if start > end, we strip away a prefix and |
@@ -9631,17 +10425,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9631 | int width = 0; | 10425 | int width = 0; |
9632 | int height = 0; | 10426 | int height = 0; |
9633 | 10427 | ||
9634 | ParcelMediaCommandEnum? commandToSend = null; | 10428 | uint commandToSend = 0; |
9635 | float time = 0.0f; // default is from start | 10429 | float time = 0.0f; // default is from start |
9636 | 10430 | ||
9637 | ScenePresence presence = null; | 10431 | ScenePresence presence = null; |
9638 | 10432 | ||
9639 | for (int i = 0; i < commandList.Data.Length; i++) | 10433 | for (int i = 0; i < commandList.Data.Length; i++) |
9640 | { | 10434 | { |
9641 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 10435 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
9642 | switch (command) | 10436 | switch (command) |
9643 | { | 10437 | { |
9644 | case ParcelMediaCommandEnum.Agent: | 10438 | case (uint)ParcelMediaCommandEnum.Agent: |
9645 | // we send only to one agent | 10439 | // we send only to one agent |
9646 | if ((i + 1) < commandList.Length) | 10440 | if ((i + 1) < commandList.Length) |
9647 | { | 10441 | { |
@@ -9658,25 +10452,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9658 | } | 10452 | } |
9659 | break; | 10453 | break; |
9660 | 10454 | ||
9661 | case ParcelMediaCommandEnum.Loop: | 10455 | case (uint)ParcelMediaCommandEnum.Loop: |
9662 | loop = 1; | 10456 | loop = 1; |
9663 | commandToSend = command; | 10457 | commandToSend = command; |
9664 | update = true; //need to send the media update packet to set looping | 10458 | update = true; //need to send the media update packet to set looping |
9665 | break; | 10459 | break; |
9666 | 10460 | ||
9667 | case ParcelMediaCommandEnum.Play: | 10461 | case (uint)ParcelMediaCommandEnum.Play: |
9668 | loop = 0; | 10462 | loop = 0; |
9669 | commandToSend = command; | 10463 | commandToSend = command; |
9670 | update = true; //need to send the media update packet to make sure it doesn't loop | 10464 | update = true; //need to send the media update packet to make sure it doesn't loop |
9671 | break; | 10465 | break; |
9672 | 10466 | ||
9673 | case ParcelMediaCommandEnum.Pause: | 10467 | case (uint)ParcelMediaCommandEnum.Pause: |
9674 | case ParcelMediaCommandEnum.Stop: | 10468 | case (uint)ParcelMediaCommandEnum.Stop: |
9675 | case ParcelMediaCommandEnum.Unload: | 10469 | case (uint)ParcelMediaCommandEnum.Unload: |
9676 | commandToSend = command; | 10470 | commandToSend = command; |
9677 | break; | 10471 | break; |
9678 | 10472 | ||
9679 | case ParcelMediaCommandEnum.Url: | 10473 | case (uint)ParcelMediaCommandEnum.Url: |
9680 | if ((i + 1) < commandList.Length) | 10474 | if ((i + 1) < commandList.Length) |
9681 | { | 10475 | { |
9682 | if (commandList.Data[i + 1] is LSL_String) | 10476 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9689,7 +10483,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9689 | } | 10483 | } |
9690 | break; | 10484 | break; |
9691 | 10485 | ||
9692 | case ParcelMediaCommandEnum.Texture: | 10486 | case (uint)ParcelMediaCommandEnum.Texture: |
9693 | if ((i + 1) < commandList.Length) | 10487 | if ((i + 1) < commandList.Length) |
9694 | { | 10488 | { |
9695 | if (commandList.Data[i + 1] is LSL_String) | 10489 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9702,7 +10496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9702 | } | 10496 | } |
9703 | break; | 10497 | break; |
9704 | 10498 | ||
9705 | case ParcelMediaCommandEnum.Time: | 10499 | case (uint)ParcelMediaCommandEnum.Time: |
9706 | if ((i + 1) < commandList.Length) | 10500 | if ((i + 1) < commandList.Length) |
9707 | { | 10501 | { |
9708 | if (commandList.Data[i + 1] is LSL_Float) | 10502 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9714,7 +10508,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9714 | } | 10508 | } |
9715 | break; | 10509 | break; |
9716 | 10510 | ||
9717 | case ParcelMediaCommandEnum.AutoAlign: | 10511 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9718 | if ((i + 1) < commandList.Length) | 10512 | if ((i + 1) < commandList.Length) |
9719 | { | 10513 | { |
9720 | if (commandList.Data[i + 1] is LSL_Integer) | 10514 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9728,7 +10522,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9728 | } | 10522 | } |
9729 | break; | 10523 | break; |
9730 | 10524 | ||
9731 | case ParcelMediaCommandEnum.Type: | 10525 | case (uint)ParcelMediaCommandEnum.Type: |
9732 | if ((i + 1) < commandList.Length) | 10526 | if ((i + 1) < commandList.Length) |
9733 | { | 10527 | { |
9734 | if (commandList.Data[i + 1] is LSL_String) | 10528 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9741,7 +10535,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9741 | } | 10535 | } |
9742 | break; | 10536 | break; |
9743 | 10537 | ||
9744 | case ParcelMediaCommandEnum.Desc: | 10538 | case (uint)ParcelMediaCommandEnum.Desc: |
9745 | if ((i + 1) < commandList.Length) | 10539 | if ((i + 1) < commandList.Length) |
9746 | { | 10540 | { |
9747 | if (commandList.Data[i + 1] is LSL_String) | 10541 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9754,7 +10548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9754 | } | 10548 | } |
9755 | break; | 10549 | break; |
9756 | 10550 | ||
9757 | case ParcelMediaCommandEnum.Size: | 10551 | case (uint)ParcelMediaCommandEnum.Size: |
9758 | if ((i + 2) < commandList.Length) | 10552 | if ((i + 2) < commandList.Length) |
9759 | { | 10553 | { |
9760 | if (commandList.Data[i + 1] is LSL_Integer) | 10554 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9824,7 +10618,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9824 | } | 10618 | } |
9825 | } | 10619 | } |
9826 | 10620 | ||
9827 | if (commandToSend != null) | 10621 | if (commandToSend != 0) |
9828 | { | 10622 | { |
9829 | // the commandList contained a start/stop/... command, too | 10623 | // the commandList contained a start/stop/... command, too |
9830 | if (presence == null) | 10624 | if (presence == null) |
@@ -9861,7 +10655,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9861 | 10655 | ||
9862 | if (aList.Data[i] != null) | 10656 | if (aList.Data[i] != null) |
9863 | { | 10657 | { |
9864 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 10658 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9865 | { | 10659 | { |
9866 | case ParcelMediaCommandEnum.Url: | 10660 | case ParcelMediaCommandEnum.Url: |
9867 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL)); | 10661 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL)); |
@@ -9918,15 +10712,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9918 | 10712 | ||
9919 | if (quick_pay_buttons.Data.Length < 4) | 10713 | if (quick_pay_buttons.Data.Length < 4) |
9920 | { | 10714 | { |
9921 | LSLError("List must have at least 4 elements"); | 10715 | int x; |
9922 | return; | 10716 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
10717 | { | ||
10718 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
10719 | } | ||
9923 | } | 10720 | } |
9924 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 10721 | int[] nPrice = new int[5]; |
9925 | 10722 | nPrice[0] = price; | |
9926 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 10723 | nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0); |
9927 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 10724 | nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1); |
9928 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 10725 | nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2); |
9929 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 10726 | nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3); |
10727 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9930 | m_host.ParentGroup.HasGroupChanged = true; | 10728 | m_host.ParentGroup.HasGroupChanged = true; |
9931 | } | 10729 | } |
9932 | 10730 | ||
@@ -9943,7 +10741,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9943 | return new LSL_Vector(); | 10741 | return new LSL_Vector(); |
9944 | } | 10742 | } |
9945 | 10743 | ||
9946 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 10744 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
10745 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
9947 | if (presence != null) | 10746 | if (presence != null) |
9948 | { | 10747 | { |
9949 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); | 10748 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); |
@@ -9965,7 +10764,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9965 | return new LSL_Rotation(); | 10764 | return new LSL_Rotation(); |
9966 | } | 10765 | } |
9967 | 10766 | ||
9968 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 10767 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
10768 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
9969 | if (presence != null) | 10769 | if (presence != null) |
9970 | { | 10770 | { |
9971 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); | 10771 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); |
@@ -10025,14 +10825,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10025 | { | 10825 | { |
10026 | m_host.AddScriptLPS(1); | 10826 | m_host.AddScriptLPS(1); |
10027 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); | 10827 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); |
10028 | if (detectedParams == null) return; // only works on the first detected avatar | 10828 | if (detectedParams == null) |
10029 | 10829 | { | |
10830 | if (m_host.ParentGroup.IsAttachment == true) | ||
10831 | { | ||
10832 | detectedParams = new DetectParams(); | ||
10833 | detectedParams.Key = m_host.OwnerID; | ||
10834 | } | ||
10835 | else | ||
10836 | { | ||
10837 | return; | ||
10838 | } | ||
10839 | } | ||
10840 | |||
10030 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 10841 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
10031 | if (avatar != null) | 10842 | if (avatar != null) |
10032 | { | 10843 | { |
10033 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, | 10844 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, |
10034 | simname, pos, lookAt); | 10845 | simname, pos, lookAt); |
10035 | } | 10846 | } |
10847 | |||
10036 | ScriptSleep(1000); | 10848 | ScriptSleep(1000); |
10037 | } | 10849 | } |
10038 | 10850 | ||
@@ -10156,12 +10968,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10156 | 10968 | ||
10157 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); | 10969 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); |
10158 | object[] data = rules.Data; | 10970 | object[] data = rules.Data; |
10159 | for (int i = 0; i < data.Length; ++i) { | 10971 | for (int i = 0; i < data.Length; ++i) |
10972 | { | ||
10160 | int type = Convert.ToInt32(data[i++].ToString()); | 10973 | int type = Convert.ToInt32(data[i++].ToString()); |
10161 | if (i >= data.Length) break; // odd number of entries => ignore the last | 10974 | if (i >= data.Length) break; // odd number of entries => ignore the last |
10162 | 10975 | ||
10163 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | 10976 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) |
10164 | switch (type) { | 10977 | switch (type) |
10978 | { | ||
10165 | case ScriptBaseClass.CAMERA_FOCUS: | 10979 | case ScriptBaseClass.CAMERA_FOCUS: |
10166 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: | 10980 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: |
10167 | case ScriptBaseClass.CAMERA_POSITION: | 10981 | case ScriptBaseClass.CAMERA_POSITION: |
@@ -10266,19 +11080,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10266 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 11080 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
10267 | { | 11081 | { |
10268 | m_host.AddScriptLPS(1); | 11082 | m_host.AddScriptLPS(1); |
10269 | string ret = String.Empty; | 11083 | |
10270 | string src1 = llBase64ToString(str1); | 11084 | if (str1 == String.Empty) |
10271 | string src2 = llBase64ToString(str2); | 11085 | return String.Empty; |
10272 | int c = 0; | 11086 | if (str2 == String.Empty) |
10273 | for (int i = 0; i < src1.Length; i++) | 11087 | return str1; |
11088 | |||
11089 | int len = str2.Length; | ||
11090 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
11091 | { | ||
11092 | while (str2.EndsWith("=")) | ||
11093 | str2 = str2.Substring(0, str2.Length - 1); | ||
11094 | |||
11095 | len = str2.Length; | ||
11096 | int mod = len % 4; | ||
11097 | |||
11098 | if (mod == 1) | ||
11099 | str2 = str2.Substring(0, str2.Length - 1); | ||
11100 | else if (mod == 2) | ||
11101 | str2 += "=="; | ||
11102 | else if (mod == 3) | ||
11103 | str2 += "="; | ||
11104 | } | ||
11105 | |||
11106 | byte[] data1; | ||
11107 | byte[] data2; | ||
11108 | try | ||
10274 | { | 11109 | { |
10275 | ret += (char) (src1[i] ^ src2[c]); | 11110 | data1 = Convert.FromBase64String(str1); |
11111 | data2 = Convert.FromBase64String(str2); | ||
11112 | } | ||
11113 | catch (Exception) | ||
11114 | { | ||
11115 | return new LSL_String(String.Empty); | ||
11116 | } | ||
10276 | 11117 | ||
10277 | c++; | 11118 | byte[] d2 = new Byte[data1.Length]; |
10278 | if (c >= src2.Length) | 11119 | int pos = 0; |
10279 | c = 0; | 11120 | |
11121 | if (data1.Length <= data2.Length) | ||
11122 | { | ||
11123 | Array.Copy(data2, 0, d2, 0, data1.Length); | ||
10280 | } | 11124 | } |
10281 | return llStringToBase64(ret); | 11125 | else |
11126 | { | ||
11127 | while (pos < data1.Length) | ||
11128 | { | ||
11129 | len = data1.Length - pos; | ||
11130 | if (len > data2.Length) | ||
11131 | len = data2.Length; | ||
11132 | |||
11133 | Array.Copy(data2, 0, d2, pos, len); | ||
11134 | pos += len; | ||
11135 | } | ||
11136 | } | ||
11137 | |||
11138 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
11139 | data1[pos] ^= d2[pos]; | ||
11140 | |||
11141 | return Convert.ToBase64String(data1); | ||
10282 | } | 11142 | } |
10283 | 11143 | ||
10284 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 11144 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -10331,16 +11191,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10331 | if (userAgent != null) | 11191 | if (userAgent != null) |
10332 | httpHeaders["User-Agent"] = userAgent; | 11192 | httpHeaders["User-Agent"] = userAgent; |
10333 | 11193 | ||
11194 | // See if the URL contains any header hacks | ||
11195 | string[] urlParts = url.Split(new char[] {'\n'}); | ||
11196 | if (urlParts.Length > 1) | ||
11197 | { | ||
11198 | // Iterate the passed headers and parse them | ||
11199 | for (int i = 1 ; i < urlParts.Length ; i++ ) | ||
11200 | { | ||
11201 | // The rest of those would be added to the body in SL. | ||
11202 | // Let's not do that. | ||
11203 | if (urlParts[i] == String.Empty) | ||
11204 | break; | ||
11205 | |||
11206 | // See if this could be a valid header | ||
11207 | string[] headerParts = urlParts[i].Split(new char[] {':'}, 2); | ||
11208 | if (headerParts.Length != 2) | ||
11209 | continue; | ||
11210 | |||
11211 | string headerName = headerParts[0].Trim(); | ||
11212 | string headerValue = headerParts[1].Trim(); | ||
11213 | |||
11214 | // Filter out headers that could be used to abuse | ||
11215 | // another system or cloak the request | ||
11216 | if (headerName.ToLower() == "x-secondlife-shard" || | ||
11217 | headerName.ToLower() == "x-secondlife-object-name" || | ||
11218 | headerName.ToLower() == "x-secondlife-object-key" || | ||
11219 | headerName.ToLower() == "x-secondlife-region" || | ||
11220 | headerName.ToLower() == "x-secondlife-local-position" || | ||
11221 | headerName.ToLower() == "x-secondlife-local-velocity" || | ||
11222 | headerName.ToLower() == "x-secondlife-local-rotation" || | ||
11223 | headerName.ToLower() == "x-secondlife-owner-name" || | ||
11224 | headerName.ToLower() == "x-secondlife-owner-key" || | ||
11225 | headerName.ToLower() == "connection" || | ||
11226 | headerName.ToLower() == "content-length" || | ||
11227 | headerName.ToLower() == "from" || | ||
11228 | headerName.ToLower() == "host" || | ||
11229 | headerName.ToLower() == "proxy-authorization" || | ||
11230 | headerName.ToLower() == "referer" || | ||
11231 | headerName.ToLower() == "trailer" || | ||
11232 | headerName.ToLower() == "transfer-encoding" || | ||
11233 | headerName.ToLower() == "via" || | ||
11234 | headerName.ToLower() == "authorization") | ||
11235 | continue; | ||
11236 | |||
11237 | httpHeaders[headerName] = headerValue; | ||
11238 | } | ||
11239 | |||
11240 | // Finally, strip any protocol specifier from the URL | ||
11241 | url = urlParts[0].Trim(); | ||
11242 | int idx = url.IndexOf(" HTTP/"); | ||
11243 | if (idx != -1) | ||
11244 | url = url.Substring(0, idx); | ||
11245 | } | ||
11246 | |||
10334 | string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; | 11247 | string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; |
10335 | Regex r = new Regex(authregex); | 11248 | Regex r = new Regex(authregex); |
10336 | int[] gnums = r.GetGroupNumbers(); | 11249 | int[] gnums = r.GetGroupNumbers(); |
10337 | Match m = r.Match(url); | 11250 | Match m = r.Match(url); |
10338 | if (m.Success) { | 11251 | if (m.Success) |
10339 | for (int i = 1; i < gnums.Length; i++) { | 11252 | { |
11253 | for (int i = 1; i < gnums.Length; i++) | ||
11254 | { | ||
10340 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; | 11255 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; |
10341 | //CaptureCollection cc = g.Captures; | 11256 | //CaptureCollection cc = g.Captures; |
10342 | } | 11257 | } |
10343 | if (m.Groups.Count == 5) { | 11258 | if (m.Groups.Count == 5) |
11259 | { | ||
10344 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); | 11260 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); |
10345 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); | 11261 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); |
10346 | } | 11262 | } |
@@ -10543,6 +11459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10543 | 11459 | ||
10544 | LSL_List ret = new LSL_List(); | 11460 | LSL_List ret = new LSL_List(); |
10545 | UUID key = new UUID(); | 11461 | UUID key = new UUID(); |
11462 | |||
11463 | |||
10546 | if (UUID.TryParse(id, out key)) | 11464 | if (UUID.TryParse(id, out key)) |
10547 | { | 11465 | { |
10548 | ScenePresence av = World.GetScenePresence(key); | 11466 | ScenePresence av = World.GetScenePresence(key); |
@@ -10560,13 +11478,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10560 | ret.Add(new LSL_String("")); | 11478 | ret.Add(new LSL_String("")); |
10561 | break; | 11479 | break; |
10562 | case ScriptBaseClass.OBJECT_POS: | 11480 | case ScriptBaseClass.OBJECT_POS: |
10563 | ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); | 11481 | Vector3 avpos; |
11482 | |||
11483 | if (av.ParentID != 0 && av.ParentPart != null) | ||
11484 | { | ||
11485 | avpos = av.OffsetPosition; | ||
11486 | |||
11487 | Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
11488 | avpos -= sitOffset; | ||
11489 | |||
11490 | avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation(); | ||
11491 | } | ||
11492 | else | ||
11493 | avpos = av.AbsolutePosition; | ||
11494 | |||
11495 | ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); | ||
10564 | break; | 11496 | break; |
10565 | case ScriptBaseClass.OBJECT_ROT: | 11497 | case ScriptBaseClass.OBJECT_ROT: |
10566 | ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); | 11498 | Quaternion avrot = av.Rotation; |
11499 | if (av.ParentID != 0 && av.ParentPart != null) | ||
11500 | { | ||
11501 | avrot = av.ParentPart.GetWorldRotation() * avrot; | ||
11502 | } | ||
11503 | ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W)); | ||
10567 | break; | 11504 | break; |
10568 | case ScriptBaseClass.OBJECT_VELOCITY: | 11505 | case ScriptBaseClass.OBJECT_VELOCITY: |
10569 | ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); | 11506 | Vector3 avvel = av.Velocity; |
11507 | ret.Add(new LSL_Vector((double)avvel.X, (double)avvel.Y, (double)avvel.Z)); | ||
10570 | break; | 11508 | break; |
10571 | case ScriptBaseClass.OBJECT_OWNER: | 11509 | case ScriptBaseClass.OBJECT_OWNER: |
10572 | ret.Add(new LSL_String(id)); | 11510 | ret.Add(new LSL_String(id)); |
@@ -10651,11 +11589,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10651 | case ScriptBaseClass.OBJECT_NAME: | 11589 | case ScriptBaseClass.OBJECT_NAME: |
10652 | ret.Add(new LSL_String(obj.Name)); | 11590 | ret.Add(new LSL_String(obj.Name)); |
10653 | break; | 11591 | break; |
10654 | case ScriptBaseClass.OBJECT_DESC: | 11592 | case ScriptBaseClass.OBJECT_DESC: |
10655 | ret.Add(new LSL_String(obj.Description)); | 11593 | ret.Add(new LSL_String(obj.Description)); |
10656 | break; | 11594 | break; |
10657 | case ScriptBaseClass.OBJECT_POS: | 11595 | case ScriptBaseClass.OBJECT_POS: |
10658 | ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); | 11596 | Vector3 opos = obj.AbsolutePosition; |
11597 | ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); | ||
10659 | break; | 11598 | break; |
10660 | case ScriptBaseClass.OBJECT_ROT: | 11599 | case ScriptBaseClass.OBJECT_ROT: |
10661 | { | 11600 | { |
@@ -10705,9 +11644,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10705 | // The value returned in SL for normal prims is prim count | 11644 | // The value returned in SL for normal prims is prim count |
10706 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); | 11645 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
10707 | break; | 11646 | break; |
10708 | // The following 3 costs I have intentionaly coded to return zero. They are part of | 11647 | |
10709 | // "Land Impact" calculations. These calculations are probably not applicable | 11648 | // costs below may need to be diferent for root parts, need to check |
10710 | // to OpenSim and are not yet complete in SL | ||
10711 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11649 | case ScriptBaseClass.OBJECT_SERVER_COST: |
10712 | // The linden calculation is here | 11650 | // The linden calculation is here |
10713 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | 11651 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight |
@@ -10715,16 +11653,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10715 | ret.Add(new LSL_Float(0)); | 11653 | ret.Add(new LSL_Float(0)); |
10716 | break; | 11654 | break; |
10717 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 11655 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
10718 | // The linden calculation is here | 11656 | // The value returned in SL for normal prims is prim count * 0.06 |
10719 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | 11657 | ret.Add(new LSL_Float(obj.StreamingCost)); |
10720 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
10721 | ret.Add(new LSL_Float(0)); | ||
10722 | break; | 11658 | break; |
10723 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 11659 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
10724 | // The linden calculation is here | 11660 | // The value returned in SL for normal prims is prim count |
10725 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | 11661 | ret.Add(new LSL_Float(obj.PhysicsCost)); |
10726 | // The value returned in SL for normal prims looks like the prim count | ||
10727 | ret.Add(new LSL_Float(0)); | ||
10728 | break; | 11662 | break; |
10729 | case ScriptBaseClass.OBJECT_CHARACTER_TIME: // Pathfinding | 11663 | case ScriptBaseClass.OBJECT_CHARACTER_TIME: // Pathfinding |
10730 | ret.Add(new LSL_Float(0)); | 11664 | ret.Add(new LSL_Float(0)); |
@@ -10981,15 +11915,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10981 | return result; | 11915 | return result; |
10982 | } | 11916 | } |
10983 | 11917 | ||
10984 | public void print(string str) | 11918 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
10985 | { | 11919 | { |
10986 | // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print | 11920 | List<SceneObjectPart> parts = GetLinkParts(link); |
10987 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); | 11921 | if (parts.Count < 1) |
10988 | if (ossl != null) | 11922 | return 0; |
10989 | { | 11923 | |
10990 | ossl.CheckThreatLevel(ThreatLevel.High, "print"); | 11924 | return GetNumberOfSides(parts[0]); |
10991 | m_log.Info("LSL print():" + str); | ||
10992 | } | ||
10993 | } | 11925 | } |
10994 | 11926 | ||
10995 | private string Name2Username(string name) | 11927 | private string Name2Username(string name) |
@@ -11034,7 +11966,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11034 | 11966 | ||
11035 | return rq.ToString(); | 11967 | return rq.ToString(); |
11036 | } | 11968 | } |
11037 | 11969 | /* | |
11970 | private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) | ||
11971 | { | ||
11972 | m_SayShoutCount = 0; | ||
11973 | } | ||
11974 | */ | ||
11038 | private struct Tri | 11975 | private struct Tri |
11039 | { | 11976 | { |
11040 | public Vector3 p1; | 11977 | public Vector3 p1; |
@@ -11174,9 +12111,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11174 | 12111 | ||
11175 | ContactResult result = new ContactResult (); | 12112 | ContactResult result = new ContactResult (); |
11176 | result.ConsumerID = group.LocalId; | 12113 | result.ConsumerID = group.LocalId; |
11177 | result.Depth = intersection.distance; | 12114 | // result.Depth = intersection.distance; |
11178 | result.Normal = intersection.normal; | 12115 | result.Normal = intersection.normal; |
11179 | result.Pos = intersection.ipoint; | 12116 | result.Pos = intersection.ipoint; |
12117 | result.Depth = Vector3.Mag(rayStart - result.Pos); | ||
11180 | 12118 | ||
11181 | contacts.Add(result); | 12119 | contacts.Add(result); |
11182 | }); | 12120 | }); |
@@ -11309,6 +12247,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11309 | 12247 | ||
11310 | return contacts[0]; | 12248 | return contacts[0]; |
11311 | } | 12249 | } |
12250 | /* | ||
12251 | // not done: | ||
12252 | private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght) | ||
12253 | { | ||
12254 | ContactResult[] contacts = null; | ||
12255 | World.ForEachSOG(delegate(SceneObjectGroup group) | ||
12256 | { | ||
12257 | if (m_host.ParentGroup == group) | ||
12258 | return; | ||
12259 | |||
12260 | if (group.IsAttachment) | ||
12261 | return; | ||
12262 | |||
12263 | if(group.RootPart.PhysActor != null) | ||
12264 | return; | ||
12265 | |||
12266 | contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght); | ||
12267 | }); | ||
12268 | return contacts; | ||
12269 | } | ||
12270 | */ | ||
11312 | 12271 | ||
11313 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | 12272 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) |
11314 | { | 12273 | { |
@@ -11350,7 +12309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11350 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | 12309 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); |
11351 | 12310 | ||
11352 | 12311 | ||
11353 | if (World.SupportsRayCastFiltered()) | 12312 | if (World.SuportsRayCastFiltered()) |
11354 | { | 12313 | { |
11355 | if (dist == 0) | 12314 | if (dist == 0) |
11356 | return list; | 12315 | return list; |
@@ -11413,6 +12372,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11413 | } | 12372 | } |
11414 | else | 12373 | else |
11415 | { | 12374 | { |
12375 | if (checkTerrain) | ||
12376 | { | ||
12377 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | ||
12378 | if (groundContact != null) | ||
12379 | results.Add((ContactResult)groundContact); | ||
12380 | } | ||
12381 | |||
11416 | if (checkAgents) | 12382 | if (checkAgents) |
11417 | { | 12383 | { |
11418 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 12384 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); |
@@ -11428,18 +12394,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11428 | } | 12394 | } |
11429 | } | 12395 | } |
11430 | 12396 | ||
11431 | if (checkTerrain) | ||
11432 | { | ||
11433 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | ||
11434 | if (groundContact != null) | ||
11435 | results.Add((ContactResult)groundContact); | ||
11436 | } | ||
11437 | |||
11438 | results.Sort(delegate(ContactResult a, ContactResult b) | 12397 | results.Sort(delegate(ContactResult a, ContactResult b) |
11439 | { | 12398 | { |
11440 | return a.Depth.CompareTo(b.Depth); | 12399 | return a.Depth.CompareTo(b.Depth); |
11441 | }); | 12400 | }); |
11442 | 12401 | ||
11443 | int values = 0; | 12402 | int values = 0; |
11444 | SceneObjectGroup thisgrp = m_host.ParentGroup; | 12403 | SceneObjectGroup thisgrp = m_host.ParentGroup; |
11445 | 12404 | ||
@@ -11532,7 +12491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11532 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: | 12491 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: |
11533 | if (!isAccount) return 0; | 12492 | if (!isAccount) return 0; |
11534 | if (estate.HasAccess(id)) return 1; | 12493 | if (estate.HasAccess(id)) return 1; |
11535 | if (estate.IsBanned(id)) | 12494 | if (estate.IsBanned(id, World.GetUserFlags(id))) |
11536 | estate.RemoveBan(id); | 12495 | estate.RemoveBan(id); |
11537 | estate.AddEstateUser(id); | 12496 | estate.AddEstateUser(id); |
11538 | break; | 12497 | break; |
@@ -11551,14 +12510,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11551 | break; | 12510 | break; |
11552 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: | 12511 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: |
11553 | if (!isAccount) return 0; | 12512 | if (!isAccount) return 0; |
11554 | if (estate.IsBanned(id)) return 1; | 12513 | if (estate.IsBanned(id, World.GetUserFlags(id))) return 1; |
11555 | EstateBan ban = new EstateBan(); | 12514 | EstateBan ban = new EstateBan(); |
11556 | ban.EstateID = estate.EstateID; | 12515 | ban.EstateID = estate.EstateID; |
11557 | ban.BannedUserID = id; | 12516 | ban.BannedUserID = id; |
11558 | estate.AddBan(ban); | 12517 | estate.AddBan(ban); |
11559 | break; | 12518 | break; |
11560 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: | 12519 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: |
11561 | if (!isAccount || !estate.IsBanned(id)) return 0; | 12520 | if (!isAccount || !estate.IsBanned(id, World.GetUserFlags(id))) return 0; |
11562 | estate.RemoveBan(id); | 12521 | estate.RemoveBan(id); |
11563 | break; | 12522 | break; |
11564 | default: return 0; | 12523 | default: return 0; |
@@ -11587,7 +12546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11587 | return 16384; | 12546 | return 16384; |
11588 | } | 12547 | } |
11589 | 12548 | ||
11590 | public LSL_Integer llGetUsedMemory() | 12549 | public virtual LSL_Integer llGetUsedMemory() |
11591 | { | 12550 | { |
11592 | m_host.AddScriptLPS(1); | 12551 | m_host.AddScriptLPS(1); |
11593 | // The value returned for LSO scripts in SL | 12552 | // The value returned for LSO scripts in SL |
@@ -11615,19 +12574,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11615 | public void llSetSoundQueueing(int queue) | 12574 | public void llSetSoundQueueing(int queue) |
11616 | { | 12575 | { |
11617 | m_host.AddScriptLPS(1); | 12576 | m_host.AddScriptLPS(1); |
11618 | NotImplemented("llSetSoundQueueing"); | ||
11619 | } | 12577 | } |
11620 | 12578 | ||
11621 | public void llCollisionSprite(string impact_sprite) | 12579 | public void llCollisionSprite(string impact_sprite) |
11622 | { | 12580 | { |
11623 | m_host.AddScriptLPS(1); | 12581 | m_host.AddScriptLPS(1); |
11624 | NotImplemented("llCollisionSprite"); | 12582 | // Viewer 2.0 broke this and it's likely LL has no intention |
12583 | // of fixing it. Therefore, letting this be a NOP seems appropriate. | ||
11625 | } | 12584 | } |
11626 | 12585 | ||
11627 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) | 12586 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) |
11628 | { | 12587 | { |
11629 | m_host.AddScriptLPS(1); | 12588 | m_host.AddScriptLPS(1); |
11630 | NotImplemented("llGodLikeRezObject"); | 12589 | |
12590 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
12591 | NotImplemented("llGodLikeRezObject"); | ||
12592 | |||
12593 | AssetBase rezAsset = World.AssetService.Get(inventory); | ||
12594 | if (rezAsset == null) | ||
12595 | { | ||
12596 | llSay(0, "Asset not found"); | ||
12597 | return; | ||
12598 | } | ||
12599 | |||
12600 | SceneObjectGroup group = null; | ||
12601 | |||
12602 | try | ||
12603 | { | ||
12604 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
12605 | group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
12606 | } | ||
12607 | catch | ||
12608 | { | ||
12609 | llSay(0, "Asset not found"); | ||
12610 | return; | ||
12611 | } | ||
12612 | |||
12613 | if (group == null) | ||
12614 | { | ||
12615 | llSay(0, "Asset not found"); | ||
12616 | return; | ||
12617 | } | ||
12618 | |||
12619 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
12620 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
12621 | |||
12622 | group.ResetIDs(); | ||
12623 | |||
12624 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
12625 | World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero); | ||
12626 | group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3); | ||
12627 | group.ScheduleGroupForFullUpdate(); | ||
12628 | |||
12629 | // objects rezzed with this method are die_at_edge by default. | ||
12630 | group.RootPart.SetDieAtEdge(true); | ||
12631 | |||
12632 | group.ResumeScripts(); | ||
12633 | |||
12634 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | ||
12635 | "object_rez", new Object[] { | ||
12636 | new LSL_String( | ||
12637 | group.RootPart.UUID.ToString()) }, | ||
12638 | new DetectParams[0])); | ||
11631 | } | 12639 | } |
11632 | 12640 | ||
11633 | public LSL_String llTransferLindenDollars(string destination, int amount) | 12641 | public LSL_String llTransferLindenDollars(string destination, int amount) |
@@ -11679,7 +12687,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11679 | } | 12687 | } |
11680 | 12688 | ||
11681 | bool result = money.ObjectGiveMoney( | 12689 | bool result = money.ObjectGiveMoney( |
11682 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | 12690 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount, txn); |
11683 | 12691 | ||
11684 | if (result) | 12692 | if (result) |
11685 | { | 12693 | { |
@@ -11704,6 +12712,598 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11704 | } | 12712 | } |
11705 | 12713 | ||
11706 | #endregion | 12714 | #endregion |
12715 | |||
12716 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
12717 | { | ||
12718 | SceneObjectGroup group = m_host.ParentGroup; | ||
12719 | |||
12720 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) | ||
12721 | return; | ||
12722 | if (group.IsAttachment) | ||
12723 | return; | ||
12724 | |||
12725 | if (frames.Data.Length > 0) // We are getting a new motion | ||
12726 | { | ||
12727 | if (group.RootPart.KeyframeMotion != null) | ||
12728 | group.RootPart.KeyframeMotion.Delete(); | ||
12729 | group.RootPart.KeyframeMotion = null; | ||
12730 | |||
12731 | int idx = 0; | ||
12732 | |||
12733 | KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; | ||
12734 | KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; | ||
12735 | |||
12736 | while (idx < options.Data.Length) | ||
12737 | { | ||
12738 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
12739 | int remain = options.Data.Length - idx; | ||
12740 | |||
12741 | switch (option) | ||
12742 | { | ||
12743 | case ScriptBaseClass.KFM_MODE: | ||
12744 | if (remain < 1) | ||
12745 | break; | ||
12746 | int modeval = (int)options.GetLSLIntegerItem(idx++); | ||
12747 | switch(modeval) | ||
12748 | { | ||
12749 | case ScriptBaseClass.KFM_FORWARD: | ||
12750 | mode = KeyframeMotion.PlayMode.Forward; | ||
12751 | break; | ||
12752 | case ScriptBaseClass.KFM_REVERSE: | ||
12753 | mode = KeyframeMotion.PlayMode.Reverse; | ||
12754 | break; | ||
12755 | case ScriptBaseClass.KFM_LOOP: | ||
12756 | mode = KeyframeMotion.PlayMode.Loop; | ||
12757 | break; | ||
12758 | case ScriptBaseClass.KFM_PING_PONG: | ||
12759 | mode = KeyframeMotion.PlayMode.PingPong; | ||
12760 | break; | ||
12761 | } | ||
12762 | break; | ||
12763 | case ScriptBaseClass.KFM_DATA: | ||
12764 | if (remain < 1) | ||
12765 | break; | ||
12766 | int dataval = (int)options.GetLSLIntegerItem(idx++); | ||
12767 | data = (KeyframeMotion.DataFormat)dataval; | ||
12768 | break; | ||
12769 | } | ||
12770 | } | ||
12771 | |||
12772 | group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); | ||
12773 | |||
12774 | idx = 0; | ||
12775 | |||
12776 | int elemLength = 2; | ||
12777 | if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) | ||
12778 | elemLength = 3; | ||
12779 | |||
12780 | List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); | ||
12781 | while (idx < frames.Data.Length) | ||
12782 | { | ||
12783 | int remain = frames.Data.Length - idx; | ||
12784 | |||
12785 | if (remain < elemLength) | ||
12786 | break; | ||
12787 | |||
12788 | KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); | ||
12789 | frame.Position = null; | ||
12790 | frame.Rotation = null; | ||
12791 | |||
12792 | if ((data & KeyframeMotion.DataFormat.Translation) != 0) | ||
12793 | { | ||
12794 | LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); | ||
12795 | frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); | ||
12796 | } | ||
12797 | if ((data & KeyframeMotion.DataFormat.Rotation) != 0) | ||
12798 | { | ||
12799 | LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); | ||
12800 | Quaternion q = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); | ||
12801 | q.Normalize(); | ||
12802 | frame.Rotation = q; | ||
12803 | } | ||
12804 | |||
12805 | float tempf = (float)frames.GetLSLFloatItem(idx++); | ||
12806 | frame.TimeMS = (int)(tempf * 1000.0f); | ||
12807 | |||
12808 | keyframes.Add(frame); | ||
12809 | } | ||
12810 | |||
12811 | group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); | ||
12812 | group.RootPart.KeyframeMotion.Start(); | ||
12813 | } | ||
12814 | else | ||
12815 | { | ||
12816 | if (group.RootPart.KeyframeMotion == null) | ||
12817 | return; | ||
12818 | |||
12819 | if (options.Data.Length == 0) | ||
12820 | { | ||
12821 | group.RootPart.KeyframeMotion.Stop(); | ||
12822 | return; | ||
12823 | } | ||
12824 | |||
12825 | int code = (int)options.GetLSLIntegerItem(0); | ||
12826 | |||
12827 | int idx = 0; | ||
12828 | |||
12829 | while (idx < options.Data.Length) | ||
12830 | { | ||
12831 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
12832 | int remain = options.Data.Length - idx; | ||
12833 | |||
12834 | switch (option) | ||
12835 | { | ||
12836 | case ScriptBaseClass.KFM_COMMAND: | ||
12837 | int cmd = (int)options.GetLSLIntegerItem(idx++); | ||
12838 | switch (cmd) | ||
12839 | { | ||
12840 | case ScriptBaseClass.KFM_CMD_PLAY: | ||
12841 | group.RootPart.KeyframeMotion.Start(); | ||
12842 | break; | ||
12843 | case ScriptBaseClass.KFM_CMD_STOP: | ||
12844 | group.RootPart.KeyframeMotion.Stop(); | ||
12845 | break; | ||
12846 | case ScriptBaseClass.KFM_CMD_PAUSE: | ||
12847 | group.RootPart.KeyframeMotion.Pause(); | ||
12848 | break; | ||
12849 | } | ||
12850 | break; | ||
12851 | } | ||
12852 | } | ||
12853 | } | ||
12854 | } | ||
12855 | |||
12856 | protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed) | ||
12857 | { | ||
12858 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | ||
12859 | |||
12860 | int idx = 0; | ||
12861 | int idxStart = 0; | ||
12862 | |||
12863 | bool positionChanged = false; | ||
12864 | Vector3 finalPos = Vector3.Zero; | ||
12865 | |||
12866 | try | ||
12867 | { | ||
12868 | while (idx < rules.Length) | ||
12869 | { | ||
12870 | ++rulesParsed; | ||
12871 | int code = rules.GetLSLIntegerItem(idx++); | ||
12872 | |||
12873 | int remain = rules.Length - idx; | ||
12874 | idxStart = idx; | ||
12875 | |||
12876 | switch (code) | ||
12877 | { | ||
12878 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
12879 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
12880 | { | ||
12881 | if (remain < 1) | ||
12882 | return null; | ||
12883 | |||
12884 | LSL_Vector v; | ||
12885 | v = rules.GetVector3Item(idx++); | ||
12886 | |||
12887 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
12888 | if (part == null) | ||
12889 | break; | ||
12890 | |||
12891 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
12892 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
12893 | if (part.LinkNum > 1) | ||
12894 | { | ||
12895 | localRot = GetPartLocalRot(part); | ||
12896 | localPos = GetPartLocalPos(part); | ||
12897 | } | ||
12898 | |||
12899 | v -= localPos; | ||
12900 | v /= localRot; | ||
12901 | |||
12902 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
12903 | |||
12904 | v = v + 2 * sitOffset; | ||
12905 | |||
12906 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
12907 | av.SendAvatarDataToAllAgents(); | ||
12908 | |||
12909 | } | ||
12910 | break; | ||
12911 | |||
12912 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
12913 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
12914 | { | ||
12915 | if (remain < 1) | ||
12916 | return null; | ||
12917 | |||
12918 | LSL_Rotation r; | ||
12919 | r = rules.GetQuaternionItem(idx++); | ||
12920 | |||
12921 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
12922 | if (part == null) | ||
12923 | break; | ||
12924 | |||
12925 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
12926 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
12927 | |||
12928 | if (part.LinkNum > 1) | ||
12929 | localRot = GetPartLocalRot(part); | ||
12930 | |||
12931 | r = r * llGetRootRotation() / localRot; | ||
12932 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
12933 | av.SendAvatarDataToAllAgents(); | ||
12934 | } | ||
12935 | break; | ||
12936 | |||
12937 | // parse rest doing nothing but number of parameters error check | ||
12938 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
12939 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
12940 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
12941 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
12942 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
12943 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
12944 | case (int)ScriptBaseClass.PRIM_NAME: | ||
12945 | case (int)ScriptBaseClass.PRIM_DESC: | ||
12946 | if (remain < 1) | ||
12947 | return null; | ||
12948 | idx++; | ||
12949 | break; | ||
12950 | |||
12951 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
12952 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
12953 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
12954 | if (remain < 2) | ||
12955 | return null; | ||
12956 | idx += 2; | ||
12957 | break; | ||
12958 | |||
12959 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
12960 | if (remain < 3) | ||
12961 | return null; | ||
12962 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
12963 | remain = rules.Length - idx; | ||
12964 | switch (code) | ||
12965 | { | ||
12966 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
12967 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
12968 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
12969 | if (remain < 6) | ||
12970 | return null; | ||
12971 | idx += 6; | ||
12972 | break; | ||
12973 | |||
12974 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
12975 | if (remain < 5) | ||
12976 | return null; | ||
12977 | idx += 5; | ||
12978 | break; | ||
12979 | |||
12980 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | ||
12981 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | ||
12982 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | ||
12983 | if (remain < 11) | ||
12984 | return null; | ||
12985 | idx += 11; | ||
12986 | break; | ||
12987 | |||
12988 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
12989 | if (remain < 2) | ||
12990 | return null; | ||
12991 | idx += 2; | ||
12992 | break; | ||
12993 | } | ||
12994 | break; | ||
12995 | |||
12996 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
12997 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
12998 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
12999 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
13000 | if (remain < 3) | ||
13001 | return null; | ||
13002 | idx += 3; | ||
13003 | break; | ||
13004 | |||
13005 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
13006 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
13007 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
13008 | if (remain < 5) | ||
13009 | return null; | ||
13010 | idx += 5; | ||
13011 | break; | ||
13012 | |||
13013 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
13014 | if (remain < 7) | ||
13015 | return null; | ||
13016 | |||
13017 | idx += 7; | ||
13018 | break; | ||
13019 | |||
13020 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
13021 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
13022 | return null; | ||
13023 | |||
13024 | return rules.GetSublist(idx, -1); | ||
13025 | } | ||
13026 | } | ||
13027 | } | ||
13028 | catch (InvalidCastException e) | ||
13029 | { | ||
13030 | ShoutError(string.Format( | ||
13031 | "{0} error running rule #{1}: arg #{2} ", | ||
13032 | originFunc, rulesParsed, idx - idxStart) + e.Message); | ||
13033 | } | ||
13034 | finally | ||
13035 | { | ||
13036 | if (positionChanged) | ||
13037 | { | ||
13038 | av.OffsetPosition = finalPos; | ||
13039 | // av.SendAvatarDataToAllAgents(); | ||
13040 | av.SendTerseUpdateToAllClients(); | ||
13041 | positionChanged = false; | ||
13042 | } | ||
13043 | } | ||
13044 | return null; | ||
13045 | } | ||
13046 | |||
13047 | public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules, ref LSL_List res) | ||
13048 | { | ||
13049 | // avatars case | ||
13050 | // replies as SL wiki | ||
13051 | |||
13052 | // SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed | ||
13053 | SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? | ||
13054 | |||
13055 | int idx = 0; | ||
13056 | while (idx < rules.Length) | ||
13057 | { | ||
13058 | int code = (int)rules.GetLSLIntegerItem(idx++); | ||
13059 | int remain = rules.Length - idx; | ||
13060 | |||
13061 | switch (code) | ||
13062 | { | ||
13063 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
13064 | res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); | ||
13065 | break; | ||
13066 | |||
13067 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
13068 | res.Add(new LSL_Integer(0)); | ||
13069 | break; | ||
13070 | |||
13071 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
13072 | res.Add(new LSL_Integer(0)); | ||
13073 | break; | ||
13074 | |||
13075 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
13076 | res.Add(new LSL_Integer(0)); | ||
13077 | break; | ||
13078 | |||
13079 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
13080 | |||
13081 | Vector3 pos = avatar.OffsetPosition; | ||
13082 | |||
13083 | Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
13084 | pos -= sitOffset; | ||
13085 | |||
13086 | if( sitPart != null) | ||
13087 | pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); | ||
13088 | |||
13089 | res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); | ||
13090 | break; | ||
13091 | |||
13092 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
13093 | // as in llGetAgentSize above | ||
13094 | // res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); | ||
13095 | Vector3 s = avatar.Appearance.AvatarSize; | ||
13096 | res.Add(new LSL_Vector(s.X, s.Y, s.Z)); | ||
13097 | |||
13098 | break; | ||
13099 | |||
13100 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
13101 | Quaternion rot = avatar.Rotation; | ||
13102 | if (sitPart != null) | ||
13103 | { | ||
13104 | rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation | ||
13105 | } | ||
13106 | |||
13107 | res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W)); | ||
13108 | break; | ||
13109 | |||
13110 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
13111 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); | ||
13112 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); | ||
13113 | res.Add(new LSL_Vector(0f,1.0f,0f)); | ||
13114 | res.Add(new LSL_Float(0.0f)); | ||
13115 | res.Add(new LSL_Vector(0, 0, 0)); | ||
13116 | res.Add(new LSL_Vector(1.0f,1.0f,0f)); | ||
13117 | res.Add(new LSL_Vector(0, 0, 0)); | ||
13118 | break; | ||
13119 | |||
13120 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
13121 | if (remain < 1) | ||
13122 | return null; | ||
13123 | |||
13124 | int face = (int)rules.GetLSLIntegerItem(idx++); | ||
13125 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13126 | { | ||
13127 | for (face = 0; face < 21; face++) | ||
13128 | { | ||
13129 | res.Add(new LSL_String("")); | ||
13130 | res.Add(new LSL_Vector(0,0,0)); | ||
13131 | res.Add(new LSL_Vector(0,0,0)); | ||
13132 | res.Add(new LSL_Float(0.0)); | ||
13133 | } | ||
13134 | } | ||
13135 | else | ||
13136 | { | ||
13137 | if (face >= 0 && face < 21) | ||
13138 | { | ||
13139 | res.Add(new LSL_String("")); | ||
13140 | res.Add(new LSL_Vector(0,0,0)); | ||
13141 | res.Add(new LSL_Vector(0,0,0)); | ||
13142 | res.Add(new LSL_Float(0.0)); | ||
13143 | } | ||
13144 | } | ||
13145 | break; | ||
13146 | |||
13147 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
13148 | if (remain < 1) | ||
13149 | return null; | ||
13150 | |||
13151 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13152 | |||
13153 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13154 | { | ||
13155 | for (face = 0; face < 21; face++) | ||
13156 | { | ||
13157 | res.Add(new LSL_Vector(0,0,0)); | ||
13158 | res.Add(new LSL_Float(0)); | ||
13159 | } | ||
13160 | } | ||
13161 | else | ||
13162 | { | ||
13163 | res.Add(new LSL_Vector(0,0,0)); | ||
13164 | res.Add(new LSL_Float(0)); | ||
13165 | } | ||
13166 | break; | ||
13167 | |||
13168 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
13169 | if (remain < 1) | ||
13170 | return null; | ||
13171 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13172 | |||
13173 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13174 | { | ||
13175 | for (face = 0; face < 21; face++) | ||
13176 | { | ||
13177 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
13178 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
13179 | } | ||
13180 | } | ||
13181 | else | ||
13182 | { | ||
13183 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
13184 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
13185 | } | ||
13186 | break; | ||
13187 | |||
13188 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
13189 | if (remain < 1) | ||
13190 | return null; | ||
13191 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13192 | |||
13193 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13194 | { | ||
13195 | for (face = 0; face < 21; face++) | ||
13196 | { | ||
13197 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
13198 | } | ||
13199 | } | ||
13200 | else | ||
13201 | { | ||
13202 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
13203 | } | ||
13204 | break; | ||
13205 | |||
13206 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
13207 | res.Add(new LSL_Integer(0)); | ||
13208 | res.Add(new LSL_Integer(0));// softness | ||
13209 | res.Add(new LSL_Float(0.0f)); // gravity | ||
13210 | res.Add(new LSL_Float(0.0f)); // friction | ||
13211 | res.Add(new LSL_Float(0.0f)); // wind | ||
13212 | res.Add(new LSL_Float(0.0f)); // tension | ||
13213 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
13214 | break; | ||
13215 | |||
13216 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
13217 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
13218 | if (remain < 1) | ||
13219 | return null; | ||
13220 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13221 | |||
13222 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13223 | { | ||
13224 | for (face = 0; face < 21; face++) | ||
13225 | { | ||
13226 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
13227 | } | ||
13228 | } | ||
13229 | else | ||
13230 | { | ||
13231 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
13232 | } | ||
13233 | break; | ||
13234 | |||
13235 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
13236 | res.Add(new LSL_Integer(0)); | ||
13237 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
13238 | res.Add(new LSL_Float(0f)); // intensity | ||
13239 | res.Add(new LSL_Float(0f)); // radius | ||
13240 | res.Add(new LSL_Float(0f)); // falloff | ||
13241 | break; | ||
13242 | |||
13243 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
13244 | if (remain < 1) | ||
13245 | return null; | ||
13246 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13247 | |||
13248 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13249 | { | ||
13250 | for (face = 0; face < 21; face++) | ||
13251 | { | ||
13252 | res.Add(new LSL_Float(0f)); | ||
13253 | } | ||
13254 | } | ||
13255 | else | ||
13256 | { | ||
13257 | res.Add(new LSL_Float(0f)); | ||
13258 | } | ||
13259 | break; | ||
13260 | |||
13261 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
13262 | res.Add(new LSL_String("")); | ||
13263 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
13264 | res.Add(new LSL_Float(1.0f)); | ||
13265 | break; | ||
13266 | |||
13267 | case (int)ScriptBaseClass.PRIM_NAME: | ||
13268 | res.Add(new LSL_String(avatar.Name)); | ||
13269 | break; | ||
13270 | |||
13271 | case (int)ScriptBaseClass.PRIM_DESC: | ||
13272 | res.Add(new LSL_String("")); | ||
13273 | break; | ||
13274 | |||
13275 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
13276 | Quaternion lrot = avatar.Rotation; | ||
13277 | |||
13278 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
13279 | { | ||
13280 | lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset | ||
13281 | } | ||
13282 | res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); | ||
13283 | break; | ||
13284 | |||
13285 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
13286 | Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part | ||
13287 | Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); | ||
13288 | lpos -= lsitOffset; | ||
13289 | |||
13290 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
13291 | { | ||
13292 | lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim | ||
13293 | } | ||
13294 | res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); | ||
13295 | break; | ||
13296 | |||
13297 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
13298 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
13299 | return null; | ||
13300 | |||
13301 | return rules.GetSublist(idx, -1); | ||
13302 | } | ||
13303 | } | ||
13304 | |||
13305 | return null; | ||
13306 | } | ||
11707 | } | 13307 | } |
11708 | 13308 | ||
11709 | public class NotecardCache | 13309 | 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 1426070..6ff6b00 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 | protected IUrlModule m_UrlModule = null; | 144 | protected IUrlModule m_UrlModule = null; |
@@ -148,6 +149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
148 | m_ScriptEngine = scriptEngine; | 149 | m_ScriptEngine = scriptEngine; |
149 | m_host = host; | 150 | m_host = host; |
150 | m_item = item; | 151 | m_item = item; |
152 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
151 | 153 | ||
152 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 154 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
153 | 155 | ||
@@ -211,7 +213,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
211 | 213 | ||
212 | internal void OSSLError(string msg) | 214 | internal void OSSLError(string msg) |
213 | { | 215 | { |
214 | throw new ScriptException("OSSL Runtime Error: " + msg); | 216 | if (m_debuggerSafe) |
217 | { | ||
218 | OSSLShoutError(msg); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | throw new ScriptException("OSSL Runtime Error: " + msg); | ||
223 | } | ||
215 | } | 224 | } |
216 | 225 | ||
217 | /// <summary> | 226 | /// <summary> |
@@ -930,18 +939,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
930 | if (target != null) | 939 | if (target != null) |
931 | { | 940 | { |
932 | UUID animID=UUID.Zero; | 941 | UUID animID=UUID.Zero; |
933 | lock (m_host.TaskInventory) | 942 | m_host.TaskInventory.LockItemsForRead(true); |
943 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
934 | { | 944 | { |
935 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 945 | if (inv.Value.Name == animation) |
936 | { | 946 | { |
937 | if (inv.Value.Name == animation) | 947 | if (inv.Value.Type == (int)AssetType.Animation) |
938 | { | 948 | animID = inv.Value.AssetID; |
939 | if (inv.Value.Type == (int)AssetType.Animation) | 949 | continue; |
940 | animID = inv.Value.AssetID; | ||
941 | continue; | ||
942 | } | ||
943 | } | 950 | } |
944 | } | 951 | } |
952 | m_host.TaskInventory.LockItemsForRead(false); | ||
945 | if (animID == UUID.Zero) | 953 | if (animID == UUID.Zero) |
946 | target.Animator.AddAnimation(animation, m_host.UUID); | 954 | target.Animator.AddAnimation(animation, m_host.UUID); |
947 | else | 955 | else |
@@ -982,6 +990,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
982 | else | 990 | else |
983 | animID = UUID.Zero; | 991 | animID = UUID.Zero; |
984 | } | 992 | } |
993 | m_host.TaskInventory.LockItemsForRead(false); | ||
985 | 994 | ||
986 | if (animID == UUID.Zero) | 995 | if (animID == UUID.Zero) |
987 | target.Animator.RemoveAnimation(animation); | 996 | target.Animator.RemoveAnimation(animation); |
@@ -1848,15 +1857,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1848 | { | 1857 | { |
1849 | UUID assetID = UUID.Zero; | 1858 | UUID assetID = UUID.Zero; |
1850 | 1859 | ||
1851 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) | 1860 | bool notecardNameIsUUID = UUID.TryParse(notecardNameOrUuid, out assetID); |
1861 | |||
1862 | if (!notecardNameIsUUID) | ||
1852 | { | 1863 | { |
1853 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1864 | assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); |
1854 | { | ||
1855 | if (item.Type == 7 && item.Name == notecardNameOrUuid) | ||
1856 | { | ||
1857 | assetID = item.AssetID; | ||
1858 | } | ||
1859 | } | ||
1860 | } | 1865 | } |
1861 | 1866 | ||
1862 | if (assetID == UUID.Zero) | 1867 | if (assetID == UUID.Zero) |
@@ -1867,7 +1872,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1867 | AssetBase a = World.AssetService.Get(assetID.ToString()); | 1872 | AssetBase a = World.AssetService.Get(assetID.ToString()); |
1868 | 1873 | ||
1869 | if (a == null) | 1874 | if (a == null) |
1870 | return UUID.Zero; | 1875 | { |
1876 | // Whoops, it's still possible here that the notecard name was properly | ||
1877 | // formatted like a UUID but isn't an asset UUID so lets look it up by name after all | ||
1878 | assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); | ||
1879 | if (assetID == UUID.Zero) | ||
1880 | return UUID.Zero; | ||
1881 | |||
1882 | if (!NotecardCache.IsCached(assetID)) | ||
1883 | { | ||
1884 | a = World.AssetService.Get(assetID.ToString()); | ||
1885 | |||
1886 | if (a == null) | ||
1887 | { | ||
1888 | return UUID.Zero; | ||
1889 | } | ||
1890 | } | ||
1891 | } | ||
1871 | 1892 | ||
1872 | string data = Encoding.UTF8.GetString(a.Data); | 1893 | string data = Encoding.UTF8.GetString(a.Data); |
1873 | NotecardCache.Cache(assetID, data); | 1894 | NotecardCache.Cache(assetID, data); |
@@ -1875,6 +1896,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1875 | 1896 | ||
1876 | return assetID; | 1897 | return assetID; |
1877 | } | 1898 | } |
1899 | protected UUID SearchTaskInventoryForAssetId(string name) | ||
1900 | { | ||
1901 | UUID assetId = UUID.Zero; | ||
1902 | m_host.TaskInventory.LockItemsForRead(true); | ||
1903 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1904 | { | ||
1905 | if (item.Type == 7 && item.Name == name) | ||
1906 | { | ||
1907 | assetId = item.AssetID; | ||
1908 | } | ||
1909 | } | ||
1910 | m_host.TaskInventory.LockItemsForRead(false); | ||
1911 | return assetId; | ||
1912 | } | ||
1878 | 1913 | ||
1879 | /// <summary> | 1914 | /// <summary> |
1880 | /// Directly get an entire notecard at once. | 1915 | /// Directly get an entire notecard at once. |
@@ -2342,7 +2377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2342 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 2377 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
2343 | m_host.AddScriptLPS(1); | 2378 | m_host.AddScriptLPS(1); |
2344 | 2379 | ||
2345 | return NpcCreate(firstname, lastname, position, notecard, false, false); | 2380 | return NpcCreate(firstname, lastname, position, notecard, true, false); |
2346 | } | 2381 | } |
2347 | 2382 | ||
2348 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) | 2383 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) |
@@ -2353,24 +2388,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2353 | return NpcCreate( | 2388 | return NpcCreate( |
2354 | firstname, lastname, position, notecard, | 2389 | firstname, lastname, position, notecard, |
2355 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, | 2390 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, |
2356 | (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | 2391 | false); |
2392 | // (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | ||
2357 | } | 2393 | } |
2358 | 2394 | ||
2359 | private LSL_Key NpcCreate( | 2395 | private LSL_Key NpcCreate( |
2360 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) | 2396 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) |
2361 | { | 2397 | { |
2398 | if (!owned) | ||
2399 | OSSLError("Unowned NPCs are unsupported"); | ||
2400 | |||
2401 | string groupTitle = String.Empty; | ||
2402 | |||
2403 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) | ||
2404 | return new LSL_Key(UUID.Zero.ToString()); | ||
2405 | |||
2406 | if (firstname != String.Empty || lastname != String.Empty) | ||
2407 | { | ||
2408 | if (firstname != "Shown outfit:") | ||
2409 | groupTitle = "- NPC -"; | ||
2410 | } | ||
2411 | |||
2362 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2412 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2363 | if (module != null) | 2413 | if (module != null) |
2364 | { | 2414 | { |
2365 | AvatarAppearance appearance = null; | 2415 | AvatarAppearance appearance = null; |
2366 | 2416 | ||
2367 | UUID id; | 2417 | // UUID id; |
2368 | if (UUID.TryParse(notecard, out id)) | 2418 | // if (UUID.TryParse(notecard, out id)) |
2369 | { | 2419 | // { |
2370 | ScenePresence clonePresence = World.GetScenePresence(id); | 2420 | // ScenePresence clonePresence = World.GetScenePresence(id); |
2371 | if (clonePresence != null) | 2421 | // if (clonePresence != null) |
2372 | appearance = clonePresence.Appearance; | 2422 | // appearance = clonePresence.Appearance; |
2373 | } | 2423 | // } |
2374 | 2424 | ||
2375 | if (appearance == null) | 2425 | if (appearance == null) |
2376 | { | 2426 | { |
@@ -2378,9 +2428,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2378 | 2428 | ||
2379 | if (appearanceSerialized != null) | 2429 | if (appearanceSerialized != null) |
2380 | { | 2430 | { |
2381 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2431 | try |
2382 | appearance = new AvatarAppearance(); | 2432 | { |
2383 | appearance.Unpack(appearanceOsd); | 2433 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2434 | appearance = new AvatarAppearance(); | ||
2435 | appearance.Unpack(appearanceOsd); | ||
2436 | } | ||
2437 | catch | ||
2438 | { | ||
2439 | return UUID.Zero.ToString(); | ||
2440 | } | ||
2384 | } | 2441 | } |
2385 | else | 2442 | else |
2386 | { | 2443 | { |
@@ -2399,6 +2456,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2399 | World, | 2456 | World, |
2400 | appearance); | 2457 | appearance); |
2401 | 2458 | ||
2459 | ScenePresence sp; | ||
2460 | if (World.TryGetScenePresence(x, out sp)) | ||
2461 | { | ||
2462 | sp.Grouptitle = groupTitle; | ||
2463 | sp.SendAvatarDataToAllAgents(); | ||
2464 | } | ||
2402 | return new LSL_Key(x.ToString()); | 2465 | return new LSL_Key(x.ToString()); |
2403 | } | 2466 | } |
2404 | 2467 | ||
@@ -2702,16 +2765,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2702 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); | 2765 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); |
2703 | m_host.AddScriptLPS(1); | 2766 | m_host.AddScriptLPS(1); |
2704 | 2767 | ||
2705 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2768 | ManualResetEvent ev = new ManualResetEvent(false); |
2706 | if (module != null) | ||
2707 | { | ||
2708 | UUID npcId = new UUID(npc.m_string); | ||
2709 | 2769 | ||
2710 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2770 | Util.FireAndForget(delegate(object x) { |
2711 | return; | 2771 | try |
2772 | { | ||
2773 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2774 | if (module != null) | ||
2775 | { | ||
2776 | UUID npcId = new UUID(npc.m_string); | ||
2712 | 2777 | ||
2713 | module.DeleteNPC(npcId, World); | 2778 | ILandObject l = World.LandChannel.GetLandObject(m_host.GroupPosition.X, m_host.GroupPosition.Y); |
2714 | } | 2779 | if (l == null || m_host.OwnerID != l.LandData.OwnerID) |
2780 | { | ||
2781 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2782 | return; | ||
2783 | } | ||
2784 | |||
2785 | module.DeleteNPC(npcId, World); | ||
2786 | } | ||
2787 | } | ||
2788 | finally | ||
2789 | { | ||
2790 | ev.Set(); | ||
2791 | } | ||
2792 | }); | ||
2793 | ev.WaitOne(); | ||
2715 | } | 2794 | } |
2716 | 2795 | ||
2717 | public void osNpcPlayAnimation(LSL_Key npc, string animation) | 2796 | public void osNpcPlayAnimation(LSL_Key npc, string animation) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index dd45406..d3ef378 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -93,7 +93,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
93 | private const int AGENT = 1; | 93 | private const int AGENT = 1; |
94 | private const int AGENT_BY_USERNAME = 0x10; | 94 | private const int AGENT_BY_USERNAME = 0x10; |
95 | private const int NPC = 0x20; | 95 | private const int NPC = 0x20; |
96 | private const int OS_NPC = 0x01000000; | ||
97 | private const int ACTIVE = 2; | 96 | private const int ACTIVE = 2; |
98 | private const int PASSIVE = 4; | 97 | private const int PASSIVE = 4; |
99 | private const int SCRIPTED = 8; | 98 | private const int SCRIPTED = 8; |
@@ -240,7 +239,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
240 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); | 239 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); |
241 | 240 | ||
242 | // Is the sensor type is AGENT and not SCRIPTED then include agents | 241 | // Is the sensor type is AGENT and not SCRIPTED then include agents |
243 | if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) | 242 | if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) |
244 | { | 243 | { |
245 | sensedEntities.AddRange(doAgentSensor(ts)); | 244 | sensedEntities.AddRange(doAgentSensor(ts)); |
246 | } | 245 | } |
@@ -339,7 +338,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
339 | float dy; | 338 | float dy; |
340 | float dz; | 339 | float dz; |
341 | 340 | ||
342 | Quaternion q = SensePoint.GetWorldRotation(); | 341 | // Quaternion q = SensePoint.RotationOffset; |
342 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | ||
343 | if (SensePoint.ParentGroup.IsAttachment) | 343 | if (SensePoint.ParentGroup.IsAttachment) |
344 | { | 344 | { |
345 | // In attachments, rotate the sensor cone with the | 345 | // In attachments, rotate the sensor cone with the |
@@ -353,7 +353,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
353 | // Position of a sensor in a child prim attached to an avatar | 353 | // Position of a sensor in a child prim attached to an avatar |
354 | // will be still wrong. | 354 | // will be still wrong. |
355 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 355 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
356 | q = avatar.Rotation * q; | 356 | fromRegionPos = avatar.AbsolutePosition; |
357 | q = avatar.Rotation; | ||
357 | } | 358 | } |
358 | 359 | ||
359 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); | 360 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
@@ -480,7 +481,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
480 | // Position of a sensor in a child prim attached to an avatar | 481 | // Position of a sensor in a child prim attached to an avatar |
481 | // will be still wrong. | 482 | // will be still wrong. |
482 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 483 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
483 | q = avatar.Rotation * q; | 484 | if (avatar == null) |
485 | return sensedEntities; | ||
486 | fromRegionPos = avatar.AbsolutePosition; | ||
487 | q = avatar.Rotation; | ||
484 | } | 488 | } |
485 | 489 | ||
486 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); | 490 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
@@ -496,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
496 | // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", | 500 | // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", |
497 | // presence.Name, presence.PresenceType, ts.name, ts.type); | 501 | // presence.Name, presence.PresenceType, ts.name, ts.type); |
498 | 502 | ||
499 | if ((ts.type & NPC) == 0 && (ts.type & OS_NPC) == 0 && presence.PresenceType == PresenceType.Npc) | 503 | if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) |
500 | { | 504 | { |
501 | INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); | 505 | INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); |
502 | if (npcData == null || !npcData.SenseAsAgent) | 506 | 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 0b14565..68aacd2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -123,25 +123,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
123 | if (Timers.Count == 0) | 123 | if (Timers.Count == 0) |
124 | return; | 124 | return; |
125 | 125 | ||
126 | Dictionary<string, TimerInfo>.ValueCollection tvals; | ||
126 | lock (TimerListLock) | 127 | lock (TimerListLock) |
127 | { | 128 | { |
128 | // Go through all timers | 129 | // Go through all timers |
129 | Dictionary<string, TimerInfo>.ValueCollection tvals = Timers.Values; | 130 | tvals = Timers.Values; |
130 | foreach (TimerInfo ts in tvals) | 131 | } |
132 | |||
133 | foreach (TimerInfo ts in tvals) | ||
134 | { | ||
135 | // Time has passed? | ||
136 | if (ts.next < DateTime.Now.Ticks) | ||
131 | { | 137 | { |
132 | // Time has passed? | 138 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
133 | if (ts.next < DateTime.Now.Ticks) | 139 | // Add it to queue |
134 | { | 140 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
135 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 141 | new EventParams("timer", new Object[0], |
136 | // Add it to queue | 142 | new DetectParams[0])); |
137 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 143 | // set next interval |
138 | new EventParams("timer", new Object[0], | 144 | |
139 | new DetectParams[0])); | 145 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
140 | // set next interval | 146 | ts.next = DateTime.Now.Ticks + ts.interval; |
141 | |||
142 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
143 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
144 | } | ||
145 | } | 147 | } |
146 | } | 148 | } |
147 | } | 149 | } |
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 4ac179a..8eeb4d2 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,7 +204,6 @@ 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); |
@@ -331,6 +332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
331 | void llSensorRemove(); | 332 | void llSensorRemove(); |
332 | 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); |
333 | void llSetAlpha(double alpha, int face); | 334 | void llSetAlpha(double alpha, int face); |
335 | void llSetAngularVelocity(LSL_Vector angvelocity, int local); | ||
334 | void llSetBuoyancy(double buoyancy); | 336 | void llSetBuoyancy(double buoyancy); |
335 | void llSetCameraAtOffset(LSL_Vector offset); | 337 | void llSetCameraAtOffset(LSL_Vector offset); |
336 | void llSetCameraEyeOffset(LSL_Vector offset); | 338 | void llSetCameraEyeOffset(LSL_Vector offset); |
@@ -357,11 +359,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
357 | void llSetParcelMusicURL(string url); | 359 | void llSetParcelMusicURL(string url); |
358 | void llSetPayPrice(int price, LSL_List quick_pay_buttons); | 360 | void llSetPayPrice(int price, LSL_List quick_pay_buttons); |
359 | void llSetPos(LSL_Vector pos); | 361 | void llSetPos(LSL_Vector pos); |
362 | LSL_Integer llSetRegionPos(LSL_Vector pos); | ||
360 | LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); | 363 | LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); |
361 | void llSetPrimitiveParams(LSL_List rules); | 364 | void llSetPrimitiveParams(LSL_List rules); |
362 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); | 365 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); |
363 | void llSetPrimURL(string url); | 366 | void llSetPrimURL(string url); |
364 | LSL_Integer llSetRegionPos(LSL_Vector pos); | ||
365 | void llSetRemoteScriptAccessPin(int pin); | 367 | void llSetRemoteScriptAccessPin(int pin); |
366 | void llSetRot(LSL_Rotation rot); | 368 | void llSetRot(LSL_Rotation rot); |
367 | void llSetScale(LSL_Vector scale); | 369 | void llSetScale(LSL_Vector scale); |
@@ -381,6 +383,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
381 | void llSetVehicleRotationParam(int param, LSL_Rotation rot); | 383 | void llSetVehicleRotationParam(int param, LSL_Rotation rot); |
382 | void llSetVehicleType(int type); | 384 | void llSetVehicleType(int type); |
383 | void llSetVehicleVectorParam(int param, LSL_Vector vec); | 385 | void llSetVehicleVectorParam(int param, LSL_Vector vec); |
386 | void llSetVelocity(LSL_Vector velocity, int local); | ||
384 | void llShout(int channelID, string text); | 387 | void llShout(int channelID, string text); |
385 | LSL_Float llSin(double f); | 388 | LSL_Float llSin(double f); |
386 | void llSitTarget(LSL_Vector offset, LSL_Rotation rot); | 389 | void llSitTarget(LSL_Vector offset, LSL_Rotation rot); |
@@ -424,9 +427,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
424 | LSL_Vector llWind(LSL_Vector offset); | 427 | LSL_Vector llWind(LSL_Vector offset); |
425 | LSL_String llXorBase64Strings(string str1, string str2); | 428 | LSL_String llXorBase64Strings(string str1, string str2); |
426 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 429 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
427 | void print(string str); | 430 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); |
431 | void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); | ||
428 | 432 | ||
429 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); | 433 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); |
434 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); | ||
430 | LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 435 | LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
431 | } | 436 | } |
432 | } | 437 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 51d0581..7eb347e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -144,7 +144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
144 | // Avatar Info Commands | 144 | // Avatar Info Commands |
145 | string osGetAgentIP(string agent); | 145 | string osGetAgentIP(string agent); |
146 | LSL_List osGetAgents(); | 146 | LSL_List osGetAgents(); |
147 | 147 | ||
148 | // Teleport commands | 148 | // Teleport commands |
149 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 149 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
150 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 150 | 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 9bf1a64..da3b31f 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; |
@@ -337,6 +337,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
337 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART | 337 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART |
338 | public const int CHANGED_MEDIA = 2048; | 338 | public const int CHANGED_MEDIA = 2048; |
339 | public const int CHANGED_ANIMATION = 16384; | 339 | public const int CHANGED_ANIMATION = 16384; |
340 | public const int CHANGED_POSITION = 32768; | ||
340 | public const int TYPE_INVALID = 0; | 341 | public const int TYPE_INVALID = 0; |
341 | public const int TYPE_INTEGER = 1; | 342 | public const int TYPE_INTEGER = 1; |
342 | public const int TYPE_FLOAT = 2; | 343 | public const int TYPE_FLOAT = 2; |
@@ -660,6 +661,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
660 | public const int PRIM_MEDIA_PERM_OWNER = 1; | 661 | public const int PRIM_MEDIA_PERM_OWNER = 1; |
661 | public const int PRIM_MEDIA_PERM_GROUP = 2; | 662 | public const int PRIM_MEDIA_PERM_GROUP = 2; |
662 | public const int PRIM_MEDIA_PERM_ANYONE = 4; | 663 | public const int PRIM_MEDIA_PERM_ANYONE = 4; |
664 | |||
665 | public const int PRIM_PHYSICS_SHAPE_TYPE = 30; | ||
666 | public const int PRIM_PHYSICS_SHAPE_PRIM = 0; | ||
667 | public const int PRIM_PHYSICS_SHAPE_CONVEX = 2; | ||
668 | public const int PRIM_PHYSICS_SHAPE_NONE = 1; | ||
669 | |||
670 | public const int PRIM_PHYSICS_MATERIAL = 31; | ||
671 | public const int DENSITY = 1; | ||
672 | public const int FRICTION = 2; | ||
673 | public const int RESTITUTION = 4; | ||
674 | public const int GRAVITY_MULTIPLIER = 8; | ||
663 | 675 | ||
664 | // extra constants for llSetPrimMediaParams | 676 | // extra constants for llSetPrimMediaParams |
665 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); | 677 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); |
@@ -732,7 +744,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
732 | 744 | ||
733 | public static readonly LSLInteger RCERR_UNKNOWN = -1; | 745 | public static readonly LSLInteger RCERR_UNKNOWN = -1; |
734 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; | 746 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; |
735 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; | 747 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = -3; |
748 | |||
749 | public const int KFM_MODE = 1; | ||
750 | public const int KFM_LOOP = 1; | ||
751 | public const int KFM_REVERSE = 3; | ||
752 | public const int KFM_FORWARD = 0; | ||
753 | public const int KFM_PING_PONG = 2; | ||
754 | public const int KFM_DATA = 2; | ||
755 | public const int KFM_TRANSLATION = 2; | ||
756 | public const int KFM_ROTATION = 1; | ||
757 | public const int KFM_COMMAND = 0; | ||
758 | public const int KFM_CMD_PLAY = 0; | ||
759 | public const int KFM_CMD_STOP = 1; | ||
760 | public const int KFM_CMD_PAUSE = 2; | ||
736 | 761 | ||
737 | /// <summary> | 762 | /// <summary> |
738 | /// process name parameter as regex | 763 | /// process name parameter as regex |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index c7a7cf6..ef71d7b 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(); |
@@ -1488,6 +1495,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1488 | m_LSL_Functions.llSetAlpha(alpha, face); | 1495 | m_LSL_Functions.llSetAlpha(alpha, face); |
1489 | } | 1496 | } |
1490 | 1497 | ||
1498 | public void llSetAngularVelocity(LSL_Vector angvelocity, int local) | ||
1499 | { | ||
1500 | m_LSL_Functions.llSetAngularVelocity(angvelocity, local); | ||
1501 | } | ||
1502 | |||
1491 | public void llSetBuoyancy(double buoyancy) | 1503 | public void llSetBuoyancy(double buoyancy) |
1492 | { | 1504 | { |
1493 | m_LSL_Functions.llSetBuoyancy(buoyancy); | 1505 | m_LSL_Functions.llSetBuoyancy(buoyancy); |
@@ -1613,6 +1625,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1613 | m_LSL_Functions.llSetPos(pos); | 1625 | m_LSL_Functions.llSetPos(pos); |
1614 | } | 1626 | } |
1615 | 1627 | ||
1628 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1629 | { | ||
1630 | return m_LSL_Functions.llSetRegionPos(pos); | ||
1631 | } | ||
1632 | |||
1616 | public void llSetPrimitiveParams(LSL_List rules) | 1633 | public void llSetPrimitiveParams(LSL_List rules) |
1617 | { | 1634 | { |
1618 | m_LSL_Functions.llSetPrimitiveParams(rules); | 1635 | m_LSL_Functions.llSetPrimitiveParams(rules); |
@@ -1628,11 +1645,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1628 | m_LSL_Functions.llSetPrimURL(url); | 1645 | m_LSL_Functions.llSetPrimURL(url); |
1629 | } | 1646 | } |
1630 | 1647 | ||
1631 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1632 | { | ||
1633 | return m_LSL_Functions.llSetRegionPos(pos); | ||
1634 | } | ||
1635 | |||
1636 | public void llSetRemoteScriptAccessPin(int pin) | 1648 | public void llSetRemoteScriptAccessPin(int pin) |
1637 | { | 1649 | { |
1638 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); | 1650 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); |
@@ -1728,6 +1740,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1728 | m_LSL_Functions.llSetVehicleVectorParam(param, vec); | 1740 | m_LSL_Functions.llSetVehicleVectorParam(param, vec); |
1729 | } | 1741 | } |
1730 | 1742 | ||
1743 | public void llSetVelocity(LSL_Vector velocity, int local) | ||
1744 | { | ||
1745 | m_LSL_Functions.llSetVelocity(velocity, local); | ||
1746 | } | ||
1747 | |||
1731 | public void llShout(int channelID, string text) | 1748 | public void llShout(int channelID, string text) |
1732 | { | 1749 | { |
1733 | m_LSL_Functions.llShout(channelID, text); | 1750 | m_LSL_Functions.llShout(channelID, text); |
@@ -1978,9 +1995,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1978 | return m_LSL_Functions.llClearLinkMedia(link, face); | 1995 | return m_LSL_Functions.llClearLinkMedia(link, face); |
1979 | } | 1996 | } |
1980 | 1997 | ||
1981 | public void print(string str) | 1998 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
1999 | { | ||
2000 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | ||
2001 | } | ||
2002 | |||
2003 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
2004 | { | ||
2005 | m_LSL_Functions.llSetKeyframedMotion(frames, options); | ||
2006 | } | ||
2007 | |||
2008 | public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density) | ||
1982 | { | 2009 | { |
1983 | m_LSL_Functions.print(str); | 2010 | m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); |
1984 | } | 2011 | } |
1985 | } | 2012 | } |
1986 | } | 2013 | } |
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); |