diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
15 files changed, 2641 insertions, 888 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 993d10f..3cbdde5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -301,6 +301,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
301 | return null; | 301 | return null; |
302 | } | 302 | } |
303 | 303 | ||
304 | public static void StateChange(IScriptEngine engine, uint localID, UUID itemID) | ||
305 | { | ||
306 | // Remove a specific script | ||
307 | |||
308 | // Remove dataserver events | ||
309 | m_Dataserver[engine].RemoveEvents(localID, itemID); | ||
310 | |||
311 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); | ||
312 | if (comms != null) | ||
313 | comms.DeleteListener(itemID); | ||
314 | |||
315 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); | ||
316 | xmlrpc.DeleteChannels(itemID); | ||
317 | xmlrpc.CancelSRDRequests(itemID); | ||
318 | |||
319 | // Remove Sensors | ||
320 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | ||
321 | |||
322 | } | ||
323 | |||
304 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) | 324 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) |
305 | { | 325 | { |
306 | List<Object> data = new List<Object>(); | 326 | List<Object> data = new List<Object>(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..b5fa6de --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Runtime.Remoting.Lifetime; | ||
33 | using OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.World.LightShare; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Region.ScriptEngine.Shared; | ||
41 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
42 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
43 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | |||
47 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
48 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
49 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
50 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
51 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
52 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
53 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
54 | |||
55 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
56 | { | ||
57 | [Serializable] | ||
58 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
59 | { | ||
60 | internal IScriptEngine m_ScriptEngine; | ||
61 | internal SceneObjectPart m_host; | ||
62 | internal TaskInventoryItem m_item; | ||
63 | internal bool m_CMFunctionsEnabled = false; | ||
64 | |||
65 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | ||
66 | { | ||
67 | m_ScriptEngine = ScriptEngine; | ||
68 | m_host = host; | ||
69 | m_item = item; | ||
70 | |||
71 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
72 | m_CMFunctionsEnabled = true; | ||
73 | } | ||
74 | |||
75 | public override Object InitializeLifetimeService() | ||
76 | { | ||
77 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
78 | |||
79 | if (lease.CurrentState == LeaseState.Initial) | ||
80 | { | ||
81 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
82 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
83 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
84 | } | ||
85 | return lease; | ||
86 | } | ||
87 | |||
88 | public Scene World | ||
89 | { | ||
90 | get { return m_ScriptEngine.World; } | ||
91 | } | ||
92 | |||
93 | public string cmDetectedCountry(int number) | ||
94 | { | ||
95 | m_host.AddScriptLPS(1); | ||
96 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); | ||
97 | if (detectedParams == null) | ||
98 | return String.Empty; | ||
99 | return detectedParams.Country; | ||
100 | } | ||
101 | |||
102 | public string cmGetAgentCountry(LSL_Key key) | ||
103 | { | ||
104 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
105 | return String.Empty; | ||
106 | |||
107 | UUID uuid; | ||
108 | |||
109 | if (!UUID.TryParse(key, out uuid)) | ||
110 | return String.Empty; | ||
111 | |||
112 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | ||
113 | return account.UserCountry; | ||
114 | } | ||
115 | } | ||
116 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d213c35..0cc3e8c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,10 +28,12 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
34 | using System.Text.RegularExpressions; | 35 | using System.Text.RegularExpressions; |
36 | using System.Timers; | ||
35 | using Nini.Config; | 37 | using Nini.Config; |
36 | using log4net; | 38 | using log4net; |
37 | using OpenMetaverse; | 39 | using OpenMetaverse; |
@@ -44,6 +46,7 @@ using OpenSim.Region.CoreModules.World.Land; | |||
44 | using OpenSim.Region.CoreModules.World.Terrain; | 46 | using OpenSim.Region.CoreModules.World.Terrain; |
45 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
46 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
47 | using OpenSim.Region.Framework.Scenes.Animation; | 50 | using OpenSim.Region.Framework.Scenes.Animation; |
48 | using OpenSim.Region.Physics.Manager; | 51 | using OpenSim.Region.Physics.Manager; |
49 | using OpenSim.Region.ScriptEngine.Shared; | 52 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -65,6 +68,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | |||
65 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 68 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
66 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 69 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
67 | using System.Reflection; | 70 | using System.Reflection; |
71 | using Timer = System.Timers.Timer; | ||
68 | 72 | ||
69 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 73 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
70 | { | 74 | { |
@@ -103,16 +107,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
103 | protected int m_notecardLineReadCharsMax = 255; | 107 | protected int m_notecardLineReadCharsMax = 255; |
104 | protected int m_scriptConsoleChannel = 0; | 108 | protected int m_scriptConsoleChannel = 0; |
105 | protected bool m_scriptConsoleChannelEnabled = false; | 109 | protected bool m_scriptConsoleChannelEnabled = false; |
110 | protected bool m_debuggerSafe = false; | ||
106 | protected IUrlModule m_UrlModule = null; | 111 | protected IUrlModule m_UrlModule = null; |
107 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 112 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
108 | new Dictionary<UUID, UserInfoCacheEntry>(); | 113 | new Dictionary<UUID, UserInfoCacheEntry>(); |
109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 114 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
115 | |||
116 | protected Timer m_ShoutSayTimer; | ||
117 | protected int m_SayShoutCount = 0; | ||
110 | 118 | ||
111 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 119 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
112 | { | 120 | { |
121 | m_ShoutSayTimer = new Timer(1000); | ||
122 | m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; | ||
123 | m_ShoutSayTimer.AutoReset = true; | ||
124 | m_ShoutSayTimer.Start(); | ||
125 | |||
113 | m_ScriptEngine = ScriptEngine; | 126 | m_ScriptEngine = ScriptEngine; |
114 | m_host = host; | 127 | m_host = host; |
115 | m_item = item; | 128 | m_item = item; |
129 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
116 | 130 | ||
117 | LoadLimits(); // read script limits from config. | 131 | LoadLimits(); // read script limits from config. |
118 | 132 | ||
@@ -172,6 +186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
172 | get { return m_ScriptEngine.World; } | 186 | get { return m_ScriptEngine.World; } |
173 | } | 187 | } |
174 | 188 | ||
189 | [DebuggerNonUserCode] | ||
175 | public void state(string newState) | 190 | public void state(string newState) |
176 | { | 191 | { |
177 | m_ScriptEngine.SetState(m_item.ItemID, newState); | 192 | m_ScriptEngine.SetState(m_item.ItemID, newState); |
@@ -181,6 +196,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
181 | /// Reset the named script. The script must be present | 196 | /// Reset the named script. The script must be present |
182 | /// in the same prim. | 197 | /// in the same prim. |
183 | /// </summary> | 198 | /// </summary> |
199 | [DebuggerNonUserCode] | ||
184 | public void llResetScript() | 200 | public void llResetScript() |
185 | { | 201 | { |
186 | m_host.AddScriptLPS(1); | 202 | m_host.AddScriptLPS(1); |
@@ -237,9 +253,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
237 | } | 253 | } |
238 | } | 254 | } |
239 | 255 | ||
256 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
257 | { | ||
258 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
259 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
260 | return ret; | ||
261 | |||
262 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
263 | |||
264 | switch (linkType) | ||
265 | { | ||
266 | case ScriptBaseClass.LINK_SET: | ||
267 | return avs; | ||
268 | |||
269 | case ScriptBaseClass.LINK_ROOT: | ||
270 | return ret; | ||
271 | |||
272 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
273 | return avs; | ||
274 | |||
275 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
276 | return avs; | ||
277 | |||
278 | case ScriptBaseClass.LINK_THIS: | ||
279 | return ret; | ||
280 | |||
281 | default: | ||
282 | if (linkType < 0) | ||
283 | return ret; | ||
284 | |||
285 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
286 | |||
287 | if (linkType <= partCount) | ||
288 | { | ||
289 | return ret; | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | linkType = linkType - partCount; | ||
294 | if (linkType > avs.Count) | ||
295 | { | ||
296 | return ret; | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | ret.Add(avs[linkType-1]); | ||
301 | return ret; | ||
302 | } | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | |||
240 | public List<SceneObjectPart> GetLinkParts(int linkType) | 307 | public List<SceneObjectPart> GetLinkParts(int linkType) |
241 | { | 308 | { |
242 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 309 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
310 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
311 | return ret; | ||
243 | ret.Add(m_host); | 312 | ret.Add(m_host); |
244 | 313 | ||
245 | switch (linkType) | 314 | switch (linkType) |
@@ -286,21 +355,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
286 | protected UUID InventoryKey(string name, int type) | 355 | protected UUID InventoryKey(string name, int type) |
287 | { | 356 | { |
288 | m_host.AddScriptLPS(1); | 357 | m_host.AddScriptLPS(1); |
289 | 358 | m_host.TaskInventory.LockItemsForRead(true); | |
290 | lock (m_host.TaskInventory) | 359 | |
360 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
291 | { | 361 | { |
292 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 362 | if (inv.Value.Name == name) |
293 | { | 363 | { |
294 | if (inv.Value.Name == name) | 364 | m_host.TaskInventory.LockItemsForRead(false); |
365 | |||
366 | if (inv.Value.Type != type) | ||
295 | { | 367 | { |
296 | if (inv.Value.Type != type) | 368 | return UUID.Zero; |
297 | return UUID.Zero; | ||
298 | |||
299 | return inv.Value.AssetID; | ||
300 | } | 369 | } |
370 | |||
371 | return inv.Value.AssetID; | ||
301 | } | 372 | } |
302 | } | 373 | } |
303 | 374 | ||
375 | m_host.TaskInventory.LockItemsForRead(false); | ||
304 | return UUID.Zero; | 376 | return UUID.Zero; |
305 | } | 377 | } |
306 | 378 | ||
@@ -308,17 +380,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
308 | { | 380 | { |
309 | m_host.AddScriptLPS(1); | 381 | m_host.AddScriptLPS(1); |
310 | 382 | ||
311 | lock (m_host.TaskInventory) | 383 | |
384 | m_host.TaskInventory.LockItemsForRead(true); | ||
385 | |||
386 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
312 | { | 387 | { |
313 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 388 | if (inv.Value.Name == name) |
314 | { | 389 | { |
315 | if (inv.Value.Name == name) | 390 | m_host.TaskInventory.LockItemsForRead(false); |
316 | { | 391 | return inv.Value.AssetID; |
317 | return inv.Value.AssetID; | ||
318 | } | ||
319 | } | 392 | } |
320 | } | 393 | } |
321 | 394 | ||
395 | m_host.TaskInventory.LockItemsForRead(false); | ||
396 | |||
397 | |||
322 | return UUID.Zero; | 398 | return UUID.Zero; |
323 | } | 399 | } |
324 | 400 | ||
@@ -460,31 +536,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
460 | 536 | ||
461 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 537 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
462 | 538 | ||
463 | /// <summary> | 539 | // Utility function for llRot2Euler |
464 | /// Convert an LSL rotation to a Euler vector. | 540 | |
465 | /// </summary> | 541 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
466 | /// <remarks> | 542 | protected double NormalizeAngle(double angle) |
467 | /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf | ||
468 | /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2 | ||
469 | /// </remarks> | ||
470 | /// <param name="r"></param> | ||
471 | /// <returns></returns> | ||
472 | public LSL_Vector llRot2Euler(LSL_Rotation r) | ||
473 | { | 543 | { |
474 | m_host.AddScriptLPS(1); | 544 | if (angle > -Math.PI && angle < Math.PI) |
545 | return angle; | ||
546 | |||
547 | int numPis = (int)(Math.PI / angle); | ||
548 | double remainder = angle - Math.PI * numPis; | ||
549 | if (numPis % 2 == 1) | ||
550 | return Math.PI - angle; | ||
551 | return remainder; | ||
552 | } | ||
475 | 553 | ||
476 | LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. | 554 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
477 | double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. | 555 | { |
478 | if (m == 0.0) return new LSL_Vector(); | 556 | m_host.AddScriptLPS(1); |
479 | double x = Math.Atan2(-v.y, v.z); | 557 | LSL_Vector eul = new LSL_Vector(); |
480 | double sin = v.x / m; | ||
481 | if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. | ||
482 | double y = Math.Asin(sin); | ||
483 | // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation | ||
484 | 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))); | ||
485 | double z = Math.Atan2(v.y, v.x); | ||
486 | 558 | ||
487 | return new LSL_Vector(x, y, z); | 559 | double sqw = q1.s*q1.s; |
560 | double sqx = q1.x*q1.x; | ||
561 | double sqy = q1.z*q1.z; | ||
562 | double sqz = q1.y*q1.y; | ||
563 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor | ||
564 | double test = q1.x*q1.z + q1.y*q1.s; | ||
565 | if (test > 0.4999*unit) { // singularity at north pole | ||
566 | eul.z = 2 * Math.Atan2(q1.x,q1.s); | ||
567 | eul.y = Math.PI/2; | ||
568 | eul.x = 0; | ||
569 | return eul; | ||
570 | } | ||
571 | if (test < -0.4999*unit) { // singularity at south pole | ||
572 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
573 | eul.y = -Math.PI/2; | ||
574 | eul.x = 0; | ||
575 | return eul; | ||
576 | } | ||
577 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
578 | eul.y = Math.Asin(2*test/unit); | ||
579 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
580 | return eul; | ||
488 | } | 581 | } |
489 | 582 | ||
490 | /* From wiki: | 583 | /* From wiki: |
@@ -686,77 +779,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
686 | { | 779 | { |
687 | //A and B should both be normalized | 780 | //A and B should both be normalized |
688 | m_host.AddScriptLPS(1); | 781 | m_host.AddScriptLPS(1); |
689 | LSL_Rotation rotBetween; | 782 | /* This method is more accurate than the SL one, and thus causes problems |
690 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 783 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
691 | // continue calculation. | 784 | |
692 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 785 | double dotProduct = LSL_Vector.Dot(a, b); |
786 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
787 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | ||
788 | double angle = Math.Acos(dotProduct / magProduct); | ||
789 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); | ||
790 | double s = Math.Sin(angle / 2); | ||
791 | |||
792 | double x = axis.x * s; | ||
793 | double y = axis.y * s; | ||
794 | double z = axis.z * s; | ||
795 | double w = Math.Cos(angle / 2); | ||
796 | |||
797 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) | ||
798 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
799 | |||
800 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | ||
801 | */ | ||
802 | |||
803 | // This method mimics the 180 errors found in SL | ||
804 | // See www.euclideanspace.com... angleBetween | ||
805 | LSL_Vector vec_a = a; | ||
806 | LSL_Vector vec_b = b; | ||
807 | |||
808 | // Eliminate zero length | ||
809 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
810 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
811 | if (vec_a_mag < 0.00001 || | ||
812 | vec_b_mag < 0.00001) | ||
693 | { | 813 | { |
694 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 814 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
695 | } | 815 | } |
696 | else | 816 | |
817 | // Normalize | ||
818 | vec_a = llVecNorm(vec_a); | ||
819 | vec_b = llVecNorm(vec_b); | ||
820 | |||
821 | // Calculate axis and rotation angle | ||
822 | LSL_Vector axis = vec_a % vec_b; | ||
823 | LSL_Float cos_theta = vec_a * vec_b; | ||
824 | |||
825 | // Check if parallel | ||
826 | if (cos_theta > 0.99999) | ||
697 | { | 827 | { |
698 | a = LSL_Vector.Norm(a); | 828 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
699 | b = LSL_Vector.Norm(b); | 829 | } |
700 | double dotProduct = LSL_Vector.Dot(a, b); | 830 | |
701 | // There are two degenerate cases possible. These are for vectors 180 or | 831 | // Check if anti-parallel |
702 | // 0 degrees apart. These have to be detected and handled individually. | 832 | else if (cos_theta < -0.99999) |
703 | // | 833 | { |
704 | // Check for vectors 180 degrees apart. | 834 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
705 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 835 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
706 | if (dotProduct < -0.9999999f) | 836 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
707 | { | 837 | } |
708 | // First assume X axis is orthogonal to the vectors. | 838 | else // other rotation |
709 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 839 | { |
710 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 840 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
711 | // Check for near zero vector. A very small non-zero number here will create | 841 | axis = llVecNorm(axis); |
712 | // a rotation in an undesired direction. | 842 | double x, y, z, s, t; |
713 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 843 | s = Math.Cos(theta); |
714 | { | 844 | t = Math.Sin(theta); |
715 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 845 | x = axis.x * t; |
716 | } | 846 | y = axis.y * t; |
717 | // If the magnitude of the vector was near zero, then assume the X axis is not | 847 | z = axis.z * t; |
718 | // orthogonal and use the Z axis instead. | 848 | return new LSL_Rotation(x,y,z,s); |
719 | else | ||
720 | { | ||
721 | // Set 180 z rotation. | ||
722 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | ||
723 | } | ||
724 | } | ||
725 | // Check for parallel vectors. | ||
726 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | ||
727 | else if (dotProduct > 0.9999999f) | ||
728 | { | ||
729 | // Set zero rotation. | ||
730 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
731 | } | ||
732 | else | ||
733 | { | ||
734 | // All special checks have been performed so get the axis of rotation. | ||
735 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
736 | // Quarternion s value is the length of the unit vector + dot product. | ||
737 | double qs = 1.0 + dotProduct; | ||
738 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | ||
739 | // Normalize the rotation. | ||
740 | double mag = LSL_Rotation.Mag(rotBetween); | ||
741 | // We shouldn't have to worry about a divide by zero here. The qs value will be | ||
742 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | ||
743 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | ||
744 | // crossProduct vector should also not be zero. | ||
745 | rotBetween.x = rotBetween.x / mag; | ||
746 | rotBetween.y = rotBetween.y / mag; | ||
747 | rotBetween.z = rotBetween.z / mag; | ||
748 | rotBetween.s = rotBetween.s / mag; | ||
749 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | ||
750 | // any longer since zero vectors are checked for at the top. | ||
751 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | ||
752 | { | ||
753 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
754 | } | ||
755 | } | ||
756 | } | 849 | } |
757 | return rotBetween; | ||
758 | } | 850 | } |
759 | 851 | ||
760 | public void llWhisper(int channelID, string text) | 852 | public void llWhisper(int channelID, string text) |
761 | { | 853 | { |
762 | m_host.AddScriptLPS(1); | 854 | m_host.AddScriptLPS(1); |
@@ -776,6 +868,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
776 | { | 868 | { |
777 | m_host.AddScriptLPS(1); | 869 | m_host.AddScriptLPS(1); |
778 | 870 | ||
871 | if (channelID == 0) | ||
872 | m_SayShoutCount++; | ||
873 | |||
874 | if (m_SayShoutCount >= 11) | ||
875 | ScriptSleep(2000); | ||
876 | |||
779 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) | 877 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) |
780 | { | 878 | { |
781 | Console.WriteLine(text); | 879 | Console.WriteLine(text); |
@@ -798,6 +896,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
798 | { | 896 | { |
799 | m_host.AddScriptLPS(1); | 897 | m_host.AddScriptLPS(1); |
800 | 898 | ||
899 | if (channelID == 0) | ||
900 | m_SayShoutCount++; | ||
901 | |||
902 | if (m_SayShoutCount >= 11) | ||
903 | ScriptSleep(2000); | ||
904 | |||
801 | if (text.Length > 1023) | 905 | if (text.Length > 1023) |
802 | text = text.Substring(0, 1023); | 906 | text = text.Substring(0, 1023); |
803 | 907 | ||
@@ -1100,10 +1204,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1100 | return detectedParams.TouchUV; | 1204 | return detectedParams.TouchUV; |
1101 | } | 1205 | } |
1102 | 1206 | ||
1207 | [DebuggerNonUserCode] | ||
1103 | public virtual void llDie() | 1208 | public virtual void llDie() |
1104 | { | 1209 | { |
1105 | m_host.AddScriptLPS(1); | 1210 | m_host.AddScriptLPS(1); |
1106 | throw new SelfDeleteException(); | 1211 | if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); |
1107 | } | 1212 | } |
1108 | 1213 | ||
1109 | public LSL_Float llGround(LSL_Vector offset) | 1214 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1176,6 +1281,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1176 | 1281 | ||
1177 | public void llSetStatus(int status, int value) | 1282 | public void llSetStatus(int status, int value) |
1178 | { | 1283 | { |
1284 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1285 | return; | ||
1179 | m_host.AddScriptLPS(1); | 1286 | m_host.AddScriptLPS(1); |
1180 | 1287 | ||
1181 | int statusrotationaxis = 0; | 1288 | int statusrotationaxis = 0; |
@@ -1407,6 +1514,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1407 | { | 1514 | { |
1408 | m_host.AddScriptLPS(1); | 1515 | m_host.AddScriptLPS(1); |
1409 | 1516 | ||
1517 | SetColor(m_host, color, face); | ||
1518 | } | ||
1519 | |||
1520 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1521 | { | ||
1522 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1523 | return; | ||
1524 | |||
1525 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1526 | Color4 texcolor; | ||
1527 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1528 | { | ||
1529 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1530 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1531 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1532 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1533 | tex.FaceTextures[face].RGBA = texcolor; | ||
1534 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1535 | return; | ||
1536 | } | ||
1537 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1538 | { | ||
1539 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1540 | { | ||
1541 | if (tex.FaceTextures[i] != null) | ||
1542 | { | ||
1543 | texcolor = tex.FaceTextures[i].RGBA; | ||
1544 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1545 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1546 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1547 | tex.FaceTextures[i].RGBA = texcolor; | ||
1548 | } | ||
1549 | texcolor = tex.DefaultTexture.RGBA; | ||
1550 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1551 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1552 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1553 | tex.DefaultTexture.RGBA = texcolor; | ||
1554 | } | ||
1555 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1556 | return; | ||
1557 | } | ||
1558 | |||
1410 | if (face == ScriptBaseClass.ALL_SIDES) | 1559 | if (face == ScriptBaseClass.ALL_SIDES) |
1411 | face = SceneObjectPart.ALL_SIDES; | 1560 | face = SceneObjectPart.ALL_SIDES; |
1412 | 1561 | ||
@@ -1415,6 +1564,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1415 | 1564 | ||
1416 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1565 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1417 | { | 1566 | { |
1567 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1568 | return; | ||
1569 | |||
1418 | Primitive.TextureEntry tex = part.Shape.Textures; | 1570 | Primitive.TextureEntry tex = part.Shape.Textures; |
1419 | MappingType textype; | 1571 | MappingType textype; |
1420 | textype = MappingType.Default; | 1572 | textype = MappingType.Default; |
@@ -1445,6 +1597,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1445 | 1597 | ||
1446 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1598 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1447 | { | 1599 | { |
1600 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1601 | return; | ||
1602 | |||
1448 | Primitive.TextureEntry tex = part.Shape.Textures; | 1603 | Primitive.TextureEntry tex = part.Shape.Textures; |
1449 | if (face >= 0 && face < GetNumberOfSides(part)) | 1604 | if (face >= 0 && face < GetNumberOfSides(part)) |
1450 | { | 1605 | { |
@@ -1470,6 +1625,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1470 | 1625 | ||
1471 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1626 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1472 | { | 1627 | { |
1628 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1629 | return; | ||
1473 | 1630 | ||
1474 | Shininess sval = new Shininess(); | 1631 | Shininess sval = new Shininess(); |
1475 | 1632 | ||
@@ -1520,6 +1677,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1520 | 1677 | ||
1521 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1678 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1522 | { | 1679 | { |
1680 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1681 | return; | ||
1682 | |||
1523 | Primitive.TextureEntry tex = part.Shape.Textures; | 1683 | Primitive.TextureEntry tex = part.Shape.Textures; |
1524 | if (face >= 0 && face < GetNumberOfSides(part)) | 1684 | if (face >= 0 && face < GetNumberOfSides(part)) |
1525 | { | 1685 | { |
@@ -1580,13 +1740,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1580 | m_host.AddScriptLPS(1); | 1740 | m_host.AddScriptLPS(1); |
1581 | 1741 | ||
1582 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1742 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1583 | 1743 | if (parts.Count > 0) | |
1584 | foreach (SceneObjectPart part in parts) | 1744 | { |
1585 | SetAlpha(part, alpha, face); | 1745 | try |
1746 | { | ||
1747 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1748 | foreach (SceneObjectPart part in parts) | ||
1749 | SetAlpha(part, alpha, face); | ||
1750 | } | ||
1751 | finally | ||
1752 | { | ||
1753 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1754 | } | ||
1755 | } | ||
1586 | } | 1756 | } |
1587 | 1757 | ||
1588 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1758 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1589 | { | 1759 | { |
1760 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1761 | return; | ||
1762 | |||
1590 | Primitive.TextureEntry tex = part.Shape.Textures; | 1763 | Primitive.TextureEntry tex = part.Shape.Textures; |
1591 | Color4 texcolor; | 1764 | Color4 texcolor; |
1592 | if (face >= 0 && face < GetNumberOfSides(part)) | 1765 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1639,7 +1812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1639 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1812 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1640 | float wind, float tension, LSL_Vector Force) | 1813 | float wind, float tension, LSL_Vector Force) |
1641 | { | 1814 | { |
1642 | if (part == null) | 1815 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1643 | return; | 1816 | return; |
1644 | 1817 | ||
1645 | if (flexi) | 1818 | if (flexi) |
@@ -1673,7 +1846,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1673 | /// <param name="falloff"></param> | 1846 | /// <param name="falloff"></param> |
1674 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1847 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1675 | { | 1848 | { |
1676 | if (part == null) | 1849 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1677 | return; | 1850 | return; |
1678 | 1851 | ||
1679 | if (light) | 1852 | if (light) |
@@ -1751,15 +1924,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1751 | m_host.AddScriptLPS(1); | 1924 | m_host.AddScriptLPS(1); |
1752 | 1925 | ||
1753 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1926 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1754 | 1927 | if (parts.Count > 0) | |
1755 | foreach (SceneObjectPart part in parts) | 1928 | { |
1756 | SetTexture(part, texture, face); | 1929 | try |
1757 | 1930 | { | |
1931 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1932 | foreach (SceneObjectPart part in parts) | ||
1933 | SetTexture(part, texture, face); | ||
1934 | } | ||
1935 | finally | ||
1936 | { | ||
1937 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1938 | } | ||
1939 | } | ||
1758 | ScriptSleep(200); | 1940 | ScriptSleep(200); |
1759 | } | 1941 | } |
1760 | 1942 | ||
1761 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1943 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1762 | { | 1944 | { |
1945 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1946 | return; | ||
1947 | |||
1763 | UUID textureID = new UUID(); | 1948 | UUID textureID = new UUID(); |
1764 | 1949 | ||
1765 | textureID = InventoryKey(texture, (int)AssetType.Texture); | 1950 | textureID = InventoryKey(texture, (int)AssetType.Texture); |
@@ -1804,6 +1989,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1804 | 1989 | ||
1805 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1990 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1806 | { | 1991 | { |
1992 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1993 | return; | ||
1994 | |||
1807 | Primitive.TextureEntry tex = part.Shape.Textures; | 1995 | Primitive.TextureEntry tex = part.Shape.Textures; |
1808 | if (face >= 0 && face < GetNumberOfSides(part)) | 1996 | if (face >= 0 && face < GetNumberOfSides(part)) |
1809 | { | 1997 | { |
@@ -1840,6 +2028,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1840 | 2028 | ||
1841 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 2029 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1842 | { | 2030 | { |
2031 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2032 | return; | ||
2033 | |||
1843 | Primitive.TextureEntry tex = part.Shape.Textures; | 2034 | Primitive.TextureEntry tex = part.Shape.Textures; |
1844 | if (face >= 0 && face < GetNumberOfSides(part)) | 2035 | if (face >= 0 && face < GetNumberOfSides(part)) |
1845 | { | 2036 | { |
@@ -1876,6 +2067,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1876 | 2067 | ||
1877 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2068 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1878 | { | 2069 | { |
2070 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2071 | return; | ||
2072 | |||
1879 | Primitive.TextureEntry tex = part.Shape.Textures; | 2073 | Primitive.TextureEntry tex = part.Shape.Textures; |
1880 | if (face >= 0 && face < GetNumberOfSides(part)) | 2074 | if (face >= 0 && face < GetNumberOfSides(part)) |
1881 | { | 2075 | { |
@@ -1980,26 +2174,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1980 | return real_vec; | 2174 | return real_vec; |
1981 | } | 2175 | } |
1982 | 2176 | ||
2177 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
2178 | { | ||
2179 | return new LSL_Integer(SetRegionPos(m_host, pos)); | ||
2180 | } | ||
2181 | |||
2182 | protected int SetRegionPos(SceneObjectPart part, LSL_Vector targetPos) | ||
2183 | { | ||
2184 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2185 | return 0; | ||
2186 | |||
2187 | SceneObjectGroup grp = part.ParentGroup; | ||
2188 | |||
2189 | if (grp.IsAttachment) | ||
2190 | return 0; | ||
2191 | |||
2192 | if (grp.RootPart.PhysActor != null && grp.RootPart.PhysActor.IsPhysical) | ||
2193 | return 0; | ||
2194 | |||
2195 | if (targetPos.x < -10.0f || targetPos.x >= (float)Constants.RegionSize || targetPos.y < -10.0f || targetPos.y >= (float)Constants.RegionSize || targetPos.z < 0 || targetPos.z >= 4096.0f) | ||
2196 | return 0; | ||
2197 | |||
2198 | float constrainedX = (float)targetPos.x; | ||
2199 | float constrainedY = (float)targetPos.y; | ||
2200 | |||
2201 | if (constrainedX < 0.0f) | ||
2202 | constrainedX = 0.0f; | ||
2203 | if (constrainedY < 0.0f) | ||
2204 | constrainedY = 0.0f; | ||
2205 | if (constrainedX >= (float)Constants.RegionSize) | ||
2206 | constrainedX = (float)Constants.RegionSize - 0.1f; | ||
2207 | if (constrainedY >= (float)Constants.RegionSize) | ||
2208 | constrainedY = (float)Constants.RegionSize -0.1f; | ||
2209 | |||
2210 | float ground = World.GetGroundHeight(constrainedX, constrainedY); | ||
2211 | |||
2212 | if (targetPos.z < ground) | ||
2213 | targetPos.z = ground; | ||
2214 | |||
2215 | Vector3 dest = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); | ||
2216 | |||
2217 | if (!World.Permissions.CanObjectEntry(grp.UUID, false, dest)) | ||
2218 | return 0; | ||
2219 | |||
2220 | grp.UpdateGroupPosition(dest); | ||
2221 | |||
2222 | return 1; | ||
2223 | } | ||
2224 | |||
1983 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2225 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1984 | { | 2226 | { |
1985 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2227 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2228 | return; | ||
2229 | |||
1986 | LSL_Vector currentPos = GetPartLocalPos(part); | 2230 | LSL_Vector currentPos = GetPartLocalPos(part); |
2231 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos); | ||
1987 | 2232 | ||
1988 | float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); | ||
1989 | bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); | ||
1990 | 2233 | ||
1991 | if (part.ParentGroup.RootPart == part) | 2234 | if (part.ParentGroup.RootPart == part) |
1992 | { | 2235 | { |
1993 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | ||
1994 | targetPos.z = ground; | ||
1995 | SceneObjectGroup parent = part.ParentGroup; | 2236 | SceneObjectGroup parent = part.ParentGroup; |
1996 | LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos); | 2237 | Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); |
1997 | parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z)); | 2238 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest)) |
2239 | return; | ||
2240 | Util.FireAndForget(delegate(object x) { | ||
2241 | parent.UpdateGroupPosition(dest); | ||
2242 | }); | ||
1998 | } | 2243 | } |
1999 | else | 2244 | else |
2000 | { | 2245 | { |
2001 | LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); | 2246 | part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); |
2002 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); | ||
2003 | SceneObjectGroup parent = part.ParentGroup; | 2247 | SceneObjectGroup parent = part.ParentGroup; |
2004 | parent.HasGroupChanged = true; | 2248 | parent.HasGroupChanged = true; |
2005 | parent.ScheduleGroupForTerseUpdate(); | 2249 | parent.ScheduleGroupForTerseUpdate(); |
@@ -2032,17 +2276,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2032 | else | 2276 | else |
2033 | { | 2277 | { |
2034 | if (part.ParentGroup.IsAttachment) | 2278 | if (part.ParentGroup.IsAttachment) |
2035 | { | ||
2036 | pos = part.AttachedPos; | 2279 | pos = part.AttachedPos; |
2037 | } | ||
2038 | else | 2280 | else |
2039 | { | ||
2040 | pos = part.AbsolutePosition; | 2281 | pos = part.AbsolutePosition; |
2041 | } | ||
2042 | } | 2282 | } |
2043 | 2283 | ||
2044 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); | ||
2045 | |||
2046 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | 2284 | return new LSL_Vector(pos.X, pos.Y, pos.Z); |
2047 | } | 2285 | } |
2048 | 2286 | ||
@@ -2051,9 +2289,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2051 | m_host.AddScriptLPS(1); | 2289 | m_host.AddScriptLPS(1); |
2052 | 2290 | ||
2053 | // try to let this work as in SL... | 2291 | // try to let this work as in SL... |
2054 | if (m_host.ParentID == 0) | 2292 | if (m_host.LinkNum < 2) |
2055 | { | 2293 | { |
2056 | // special case: If we are root, rotate complete SOG to new rotation | 2294 | // Special case: If we are root, rotate complete SOG to new |
2295 | // rotation. | ||
2296 | // We are root if the link number is 0 (single prim) or 1 | ||
2297 | // (root prim). ParentID may be nonzero in attachments and | ||
2298 | // using it would cause attachments and HUDs to rotate | ||
2299 | // to the wrong positions. | ||
2057 | SetRot(m_host, Rot2Quaternion(rot)); | 2300 | SetRot(m_host, Rot2Quaternion(rot)); |
2058 | } | 2301 | } |
2059 | else | 2302 | else |
@@ -2078,6 +2321,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2078 | 2321 | ||
2079 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2322 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2080 | { | 2323 | { |
2324 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2325 | return; | ||
2326 | |||
2081 | part.UpdateRotation(rot); | 2327 | part.UpdateRotation(rot); |
2082 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2328 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2083 | 2329 | ||
@@ -2232,13 +2478,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2232 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 2478 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
2233 | { | 2479 | { |
2234 | m_host.AddScriptLPS(1); | 2480 | m_host.AddScriptLPS(1); |
2235 | m_host.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); | 2481 | m_host.ParentGroup.RootPart.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); |
2236 | } | 2482 | } |
2237 | 2483 | ||
2238 | public void llSetTorque(LSL_Vector torque, int local) | 2484 | public void llSetTorque(LSL_Vector torque, int local) |
2239 | { | 2485 | { |
2240 | m_host.AddScriptLPS(1); | 2486 | m_host.AddScriptLPS(1); |
2241 | m_host.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); | 2487 | m_host.ParentGroup.RootPart.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); |
2242 | } | 2488 | } |
2243 | 2489 | ||
2244 | public LSL_Vector llGetTorque() | 2490 | public LSL_Vector llGetTorque() |
@@ -2840,35 +3086,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2840 | public void llLookAt(LSL_Vector target, double strength, double damping) | 3086 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2841 | { | 3087 | { |
2842 | m_host.AddScriptLPS(1); | 3088 | m_host.AddScriptLPS(1); |
2843 | // Determine where we are looking from | ||
2844 | LSL_Vector from = llGetPos(); | ||
2845 | 3089 | ||
2846 | // Work out the normalised vector from the source to the target | 3090 | // Get the normalized vector to the target |
2847 | LSL_Vector delta = llVecNorm(target - from); | 3091 | LSL_Vector d1 = llVecNorm(target - llGetPos()); |
2848 | LSL_Vector angle = new LSL_Vector(0,0,0); | ||
2849 | 3092 | ||
2850 | // Calculate the yaw | 3093 | // Get the bearing (yaw) |
2851 | // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system | 3094 | LSL_Vector a1 = new LSL_Vector(0,0,0); |
2852 | angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO; | 3095 | a1.z = llAtan2(d1.y, d1.x); |
2853 | 3096 | ||
2854 | // Calculate pitch | 3097 | // Get the elevation (pitch) |
2855 | angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z))); | 3098 | LSL_Vector a2 = new LSL_Vector(0,0,0); |
3099 | a2.y= -llAtan2(d1.z, llSqrt((d1.x * d1.x) + (d1.y * d1.y))); | ||
2856 | 3100 | ||
2857 | // we need to convert from a vector describing | 3101 | LSL_Rotation r1 = llEuler2Rot(a1); |
2858 | // the angles of rotation in radians into rotation value | 3102 | LSL_Rotation r2 = llEuler2Rot(a2); |
2859 | LSL_Rotation rot = llEuler2Rot(angle); | 3103 | LSL_Rotation r3 = new LSL_Rotation(0.000000, 0.707107, 0.000000, 0.707107); |
2860 | |||
2861 | // Per discussion with Melanie, for non-physical objects llLookAt appears to simply | ||
2862 | // set the rotation of the object, copy that behavior | ||
2863 | PhysicsActor pa = m_host.PhysActor; | ||
2864 | 3104 | ||
2865 | if (strength == 0 || pa == null || !pa.IsPhysical) | 3105 | if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) |
2866 | { | 3106 | { |
2867 | llSetRot(rot); | 3107 | // Do nothing if either value is 0 (this has been checked in SL) |
3108 | if (strength <= 0.0 || damping <= 0.0) | ||
3109 | return; | ||
3110 | |||
3111 | llSetRot(r3 * r2 * r1); | ||
2868 | } | 3112 | } |
2869 | else | 3113 | else |
2870 | { | 3114 | { |
2871 | m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping); | 3115 | if (strength == 0) |
3116 | { | ||
3117 | llSetRot(r3 * r2 * r1); | ||
3118 | return; | ||
3119 | } | ||
3120 | |||
3121 | m_host.StartLookAt(Rot2Quaternion(r3 * r2 * r1), (float)strength, (float)damping); | ||
2872 | } | 3122 | } |
2873 | } | 3123 | } |
2874 | 3124 | ||
@@ -2914,17 +3164,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2914 | } | 3164 | } |
2915 | else | 3165 | else |
2916 | { | 3166 | { |
2917 | if (m_host.IsRoot) | 3167 | // new SL always returns object mass |
2918 | { | 3168 | // if (m_host.IsRoot) |
3169 | // { | ||
2919 | return m_host.ParentGroup.GetMass(); | 3170 | return m_host.ParentGroup.GetMass(); |
2920 | } | 3171 | // } |
2921 | else | 3172 | // else |
2922 | { | 3173 | // { |
2923 | return m_host.GetMass(); | 3174 | // return m_host.GetMass(); |
2924 | } | 3175 | // } |
2925 | } | 3176 | } |
2926 | } | 3177 | } |
2927 | 3178 | ||
3179 | |||
3180 | public LSL_Float llGetMassMKS() | ||
3181 | { | ||
3182 | return 100f * llGetMass(); | ||
3183 | } | ||
3184 | |||
2928 | public void llCollisionFilter(string name, string id, int accept) | 3185 | public void llCollisionFilter(string name, string id, int accept) |
2929 | { | 3186 | { |
2930 | m_host.AddScriptLPS(1); | 3187 | m_host.AddScriptLPS(1); |
@@ -3032,9 +3289,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3032 | { | 3289 | { |
3033 | m_host.AddScriptLPS(1); | 3290 | m_host.AddScriptLPS(1); |
3034 | 3291 | ||
3035 | // if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
3036 | // return; | ||
3037 | |||
3038 | if (m_item.PermsGranter != m_host.OwnerID) | 3292 | if (m_item.PermsGranter != m_host.OwnerID) |
3039 | return; | 3293 | return; |
3040 | 3294 | ||
@@ -3077,6 +3331,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3077 | 3331 | ||
3078 | public void llInstantMessage(string user, string message) | 3332 | public void llInstantMessage(string user, string message) |
3079 | { | 3333 | { |
3334 | UUID result; | ||
3335 | if (!UUID.TryParse(user, out result)) | ||
3336 | { | ||
3337 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3338 | ScriptSleep(2000); | ||
3339 | return; | ||
3340 | } | ||
3341 | |||
3342 | |||
3080 | m_host.AddScriptLPS(1); | 3343 | m_host.AddScriptLPS(1); |
3081 | 3344 | ||
3082 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3345 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3091,14 +3354,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3091 | UUID friendTransactionID = UUID.Random(); | 3354 | UUID friendTransactionID = UUID.Random(); |
3092 | 3355 | ||
3093 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3356 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
3094 | 3357 | ||
3095 | GridInstantMessage msg = new GridInstantMessage(); | 3358 | GridInstantMessage msg = new GridInstantMessage(); |
3096 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3359 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
3097 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3360 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3098 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | 3361 | msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here |
3099 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3362 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3100 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3363 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3101 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3364 | // DateTime dt = DateTime.UtcNow; |
3365 | // | ||
3366 | // // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3367 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3368 | // | ||
3369 | // try | ||
3370 | // { | ||
3371 | // // Convert that to the PST timezone | ||
3372 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3373 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3374 | // } | ||
3375 | // catch | ||
3376 | // { | ||
3377 | // // No logging here, as it could be VERY spammy | ||
3378 | // } | ||
3379 | // | ||
3380 | // // And make it look local again to fool the unix time util | ||
3381 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3382 | |||
3383 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
3384 | |||
3102 | //if (client != null) | 3385 | //if (client != null) |
3103 | //{ | 3386 | //{ |
3104 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3387 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3112,12 +3395,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3112 | msg.message = message.Substring(0, 1024); | 3395 | msg.message = message.Substring(0, 1024); |
3113 | else | 3396 | else |
3114 | msg.message = message; | 3397 | msg.message = message; |
3115 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3398 | msg.dialog = (byte)19; // MessageFromObject |
3116 | msg.fromGroup = false;// fromGroup; | 3399 | msg.fromGroup = false;// fromGroup; |
3117 | msg.offline = (byte)0; //offline; | 3400 | msg.offline = (byte)0; //offline; |
3118 | msg.ParentEstateID = 0; //ParentEstateID; | 3401 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3119 | msg.Position = new Vector3(m_host.AbsolutePosition); | 3402 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3120 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3403 | msg.RegionID = World.RegionInfo.RegionID.Guid; |
3121 | msg.binaryBucket | 3404 | msg.binaryBucket |
3122 | = Util.StringToBytes256( | 3405 | = Util.StringToBytes256( |
3123 | "{0}/{1}/{2}/{3}", | 3406 | "{0}/{1}/{2}/{3}", |
@@ -3145,7 +3428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3145 | } | 3428 | } |
3146 | 3429 | ||
3147 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3430 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3148 | llSleep(EMAIL_PAUSE_TIME); | 3431 | ScriptSleep(EMAIL_PAUSE_TIME * 1000); |
3149 | } | 3432 | } |
3150 | 3433 | ||
3151 | public void llGetNextEmail(string address, string subject) | 3434 | public void llGetNextEmail(string address, string subject) |
@@ -3394,15 +3677,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3394 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | | 3677 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | |
3395 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | 3678 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | |
3396 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | | 3679 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | |
3680 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | | ||
3397 | ScriptBaseClass.PERMISSION_ATTACH; | 3681 | ScriptBaseClass.PERMISSION_ATTACH; |
3398 | 3682 | ||
3399 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3683 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3400 | { | 3684 | { |
3401 | lock (m_host.TaskInventory) | 3685 | m_host.TaskInventory.LockItemsForWrite(true); |
3402 | { | 3686 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3403 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3687 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3404 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | 3688 | m_host.TaskInventory.LockItemsForWrite(false); |
3405 | } | ||
3406 | 3689 | ||
3407 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 3690 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3408 | "run_time_permissions", new Object[] { | 3691 | "run_time_permissions", new Object[] { |
@@ -3412,28 +3695,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3412 | return; | 3695 | return; |
3413 | } | 3696 | } |
3414 | } | 3697 | } |
3415 | else if (m_host.SitTargetAvatar == agentID) // Sitting avatar | 3698 | else |
3416 | { | 3699 | { |
3417 | // When agent is sitting, certain permissions are implicit if requested from sitting agent | 3700 | bool sitting = false; |
3418 | int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | 3701 | if (m_host.SitTargetAvatar == agentID) |
3419 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | | 3702 | { |
3420 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | | 3703 | sitting = true; |
3421 | ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | 3704 | } |
3705 | else | ||
3706 | { | ||
3707 | foreach (SceneObjectPart p in m_host.ParentGroup.Parts) | ||
3708 | { | ||
3709 | if (p.SitTargetAvatar == agentID) | ||
3710 | sitting = true; | ||
3711 | } | ||
3712 | } | ||
3422 | 3713 | ||
3423 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3714 | if (sitting) |
3424 | { | 3715 | { |
3425 | lock (m_host.TaskInventory) | 3716 | // When agent is sitting, certain permissions are implicit if requested from sitting agent |
3717 | int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | ||
3718 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | | ||
3719 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | | ||
3720 | ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | ||
3721 | |||
3722 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | ||
3426 | { | 3723 | { |
3724 | m_host.TaskInventory.LockItemsForWrite(true); | ||
3427 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3725 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3428 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | 3726 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3429 | } | 3727 | m_host.TaskInventory.LockItemsForWrite(false); |
3430 | 3728 | ||
3431 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 3729 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3432 | "run_time_permissions", new Object[] { | 3730 | "run_time_permissions", new Object[] { |
3433 | new LSL_Integer(perm) }, | 3731 | new LSL_Integer(perm) }, |
3434 | new DetectParams[0])); | 3732 | new DetectParams[0])); |
3435 | 3733 | ||
3436 | return; | 3734 | return; |
3735 | } | ||
3437 | } | 3736 | } |
3438 | } | 3737 | } |
3439 | 3738 | ||
@@ -3447,11 +3746,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3447 | 3746 | ||
3448 | if (!m_waitingForScriptAnswer) | 3747 | if (!m_waitingForScriptAnswer) |
3449 | { | 3748 | { |
3450 | lock (m_host.TaskInventory) | 3749 | m_host.TaskInventory.LockItemsForWrite(true); |
3451 | { | 3750 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3452 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 3751 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; |
3453 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; | 3752 | m_host.TaskInventory.LockItemsForWrite(false); |
3454 | } | ||
3455 | 3753 | ||
3456 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3754 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3457 | m_waitingForScriptAnswer=true; | 3755 | m_waitingForScriptAnswer=true; |
@@ -3481,11 +3779,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3481 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3779 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3482 | llReleaseControls(); | 3780 | llReleaseControls(); |
3483 | 3781 | ||
3484 | lock (m_host.TaskInventory) | 3782 | m_host.TaskInventory.LockItemsForWrite(true); |
3485 | { | 3783 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; |
3486 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; | 3784 | m_host.TaskInventory.LockItemsForWrite(false); |
3487 | } | 3785 | |
3488 | |||
3489 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 3786 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3490 | "run_time_permissions", new Object[] { | 3787 | "run_time_permissions", new Object[] { |
3491 | new LSL_Integer(answer) }, | 3788 | new LSL_Integer(answer) }, |
@@ -3528,14 +3825,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3528 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3825 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3529 | { | 3826 | { |
3530 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3827 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3531 | 3828 | if (parts.Count > 0) | |
3532 | foreach (SceneObjectPart part in parts) | 3829 | { |
3533 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3830 | try |
3831 | { | ||
3832 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3833 | foreach (SceneObjectPart part in parts) | ||
3834 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3835 | } | ||
3836 | finally | ||
3837 | { | ||
3838 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3839 | } | ||
3840 | } | ||
3534 | } | 3841 | } |
3535 | 3842 | ||
3536 | public void llCreateLink(string target, int parent) | 3843 | public void llCreateLink(string target, int parent) |
3537 | { | 3844 | { |
3538 | m_host.AddScriptLPS(1); | 3845 | m_host.AddScriptLPS(1); |
3846 | |||
3539 | UUID targetID; | 3847 | UUID targetID; |
3540 | 3848 | ||
3541 | if (!UUID.TryParse(target, out targetID)) | 3849 | if (!UUID.TryParse(target, out targetID)) |
@@ -3641,10 +3949,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3641 | // Restructuring Multiple Prims. | 3949 | // Restructuring Multiple Prims. |
3642 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 3950 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
3643 | parts.Remove(parentPrim.RootPart); | 3951 | parts.Remove(parentPrim.RootPart); |
3644 | foreach (SceneObjectPart part in parts) | 3952 | if (parts.Count > 0) |
3645 | { | 3953 | { |
3646 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3954 | try |
3955 | { | ||
3956 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3957 | foreach (SceneObjectPart part in parts) | ||
3958 | { | ||
3959 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3960 | } | ||
3961 | } | ||
3962 | finally | ||
3963 | { | ||
3964 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3965 | } | ||
3647 | } | 3966 | } |
3967 | |||
3648 | parentPrim.HasGroupChanged = true; | 3968 | parentPrim.HasGroupChanged = true; |
3649 | parentPrim.ScheduleGroupForFullUpdate(); | 3969 | parentPrim.ScheduleGroupForFullUpdate(); |
3650 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3970 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3653,12 +3973,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3653 | { | 3973 | { |
3654 | SceneObjectPart newRoot = parts[0]; | 3974 | SceneObjectPart newRoot = parts[0]; |
3655 | parts.Remove(newRoot); | 3975 | parts.Remove(newRoot); |
3656 | foreach (SceneObjectPart part in parts) | 3976 | |
3977 | try | ||
3657 | { | 3978 | { |
3658 | // Required for linking | 3979 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3659 | part.ClearUpdateSchedule(); | 3980 | foreach (SceneObjectPart part in parts) |
3660 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3981 | { |
3982 | part.ClearUpdateSchedule(); | ||
3983 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3984 | } | ||
3661 | } | 3985 | } |
3986 | finally | ||
3987 | { | ||
3988 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3989 | } | ||
3990 | |||
3991 | |||
3662 | newRoot.ParentGroup.HasGroupChanged = true; | 3992 | newRoot.ParentGroup.HasGroupChanged = true; |
3663 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3993 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3664 | } | 3994 | } |
@@ -3678,6 +4008,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3678 | public void llBreakAllLinks() | 4008 | public void llBreakAllLinks() |
3679 | { | 4009 | { |
3680 | m_host.AddScriptLPS(1); | 4010 | m_host.AddScriptLPS(1); |
4011 | |||
4012 | TaskInventoryItem item = m_item; | ||
4013 | |||
4014 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | ||
4015 | && !m_automaticLinkPermission) | ||
4016 | { | ||
4017 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | ||
4018 | return; | ||
4019 | } | ||
4020 | |||
3681 | SceneObjectGroup parentPrim = m_host.ParentGroup; | 4021 | SceneObjectGroup parentPrim = m_host.ParentGroup; |
3682 | if (parentPrim.AttachmentPoint != 0) | 4022 | if (parentPrim.AttachmentPoint != 0) |
3683 | return; // Fail silently if attached | 4023 | return; // Fail silently if attached |
@@ -3697,25 +4037,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3697 | public LSL_String llGetLinkKey(int linknum) | 4037 | public LSL_String llGetLinkKey(int linknum) |
3698 | { | 4038 | { |
3699 | m_host.AddScriptLPS(1); | 4039 | m_host.AddScriptLPS(1); |
3700 | List<UUID> keytable = new List<UUID>(); | ||
3701 | // parse for sitting avatare-uuids | ||
3702 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | ||
3703 | { | ||
3704 | if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID)) | ||
3705 | keytable.Add(presence.UUID); | ||
3706 | }); | ||
3707 | |||
3708 | int totalprims = m_host.ParentGroup.PrimCount + keytable.Count; | ||
3709 | if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) | ||
3710 | { | ||
3711 | return keytable[totalprims - linknum].ToString(); | ||
3712 | } | ||
3713 | |||
3714 | if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && keytable.Count == 1) | ||
3715 | { | ||
3716 | return m_host.UUID.ToString(); | ||
3717 | } | ||
3718 | |||
3719 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | 4040 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); |
3720 | if (part != null) | 4041 | if (part != null) |
3721 | { | 4042 | { |
@@ -3723,6 +4044,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3723 | } | 4044 | } |
3724 | else | 4045 | else |
3725 | { | 4046 | { |
4047 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) | ||
4048 | { | ||
4049 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
4050 | |||
4051 | if (linknum < 0) | ||
4052 | return UUID.Zero.ToString(); | ||
4053 | |||
4054 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); | ||
4055 | if (avatars.Count > linknum) | ||
4056 | { | ||
4057 | return avatars[linknum].UUID.ToString(); | ||
4058 | } | ||
4059 | } | ||
3726 | return UUID.Zero.ToString(); | 4060 | return UUID.Zero.ToString(); |
3727 | } | 4061 | } |
3728 | } | 4062 | } |
@@ -3822,17 +4156,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3822 | m_host.AddScriptLPS(1); | 4156 | m_host.AddScriptLPS(1); |
3823 | int count = 0; | 4157 | int count = 0; |
3824 | 4158 | ||
3825 | lock (m_host.TaskInventory) | 4159 | m_host.TaskInventory.LockItemsForRead(true); |
4160 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3826 | { | 4161 | { |
3827 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4162 | if (inv.Value.Type == type || type == -1) |
3828 | { | 4163 | { |
3829 | if (inv.Value.Type == type || type == -1) | 4164 | count = count + 1; |
3830 | { | ||
3831 | count = count + 1; | ||
3832 | } | ||
3833 | } | 4165 | } |
3834 | } | 4166 | } |
3835 | 4167 | ||
4168 | m_host.TaskInventory.LockItemsForRead(false); | ||
3836 | return count; | 4169 | return count; |
3837 | } | 4170 | } |
3838 | 4171 | ||
@@ -3841,16 +4174,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3841 | m_host.AddScriptLPS(1); | 4174 | m_host.AddScriptLPS(1); |
3842 | ArrayList keys = new ArrayList(); | 4175 | ArrayList keys = new ArrayList(); |
3843 | 4176 | ||
3844 | lock (m_host.TaskInventory) | 4177 | m_host.TaskInventory.LockItemsForRead(true); |
4178 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3845 | { | 4179 | { |
3846 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4180 | if (inv.Value.Type == type || type == -1) |
3847 | { | 4181 | { |
3848 | if (inv.Value.Type == type || type == -1) | 4182 | keys.Add(inv.Value.Name); |
3849 | { | ||
3850 | keys.Add(inv.Value.Name); | ||
3851 | } | ||
3852 | } | 4183 | } |
3853 | } | 4184 | } |
4185 | m_host.TaskInventory.LockItemsForRead(false); | ||
3854 | 4186 | ||
3855 | if (keys.Count == 0) | 4187 | if (keys.Count == 0) |
3856 | { | 4188 | { |
@@ -3887,25 +4219,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3887 | } | 4219 | } |
3888 | 4220 | ||
3889 | // move the first object found with this inventory name | 4221 | // move the first object found with this inventory name |
3890 | lock (m_host.TaskInventory) | 4222 | m_host.TaskInventory.LockItemsForRead(true); |
4223 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3891 | { | 4224 | { |
3892 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4225 | if (inv.Value.Name == inventory) |
3893 | { | 4226 | { |
3894 | if (inv.Value.Name == inventory) | 4227 | found = true; |
3895 | { | 4228 | objId = inv.Key; |
3896 | found = true; | 4229 | assetType = inv.Value.Type; |
3897 | objId = inv.Key; | 4230 | objName = inv.Value.Name; |
3898 | assetType = inv.Value.Type; | 4231 | break; |
3899 | objName = inv.Value.Name; | ||
3900 | break; | ||
3901 | } | ||
3902 | } | 4232 | } |
3903 | } | 4233 | } |
4234 | m_host.TaskInventory.LockItemsForRead(false); | ||
3904 | 4235 | ||
3905 | if (!found) | 4236 | if (!found) |
3906 | { | 4237 | { |
3907 | llSay(0, String.Format("Could not find object '{0}'", inventory)); | 4238 | llSay(0, String.Format("Could not find object '{0}'", inventory)); |
3908 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4239 | return; |
4240 | // throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | ||
3909 | } | 4241 | } |
3910 | 4242 | ||
3911 | // check if destination is an object | 4243 | // check if destination is an object |
@@ -3931,48 +4263,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3931 | return; | 4263 | return; |
3932 | } | 4264 | } |
3933 | } | 4265 | } |
4266 | |||
3934 | // destination is an avatar | 4267 | // destination is an avatar |
3935 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4268 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
3936 | 4269 | ||
3937 | if (agentItem == null) | 4270 | if (agentItem == null) |
3938 | return; | 4271 | return; |
3939 | 4272 | ||
3940 | byte[] bucket = new byte[17]; | 4273 | byte[] bucket = new byte[1]; |
3941 | bucket[0] = (byte)assetType; | 4274 | bucket[0] = (byte)assetType; |
3942 | byte[] objBytes = agentItem.ID.GetBytes(); | 4275 | //byte[] objBytes = agentItem.ID.GetBytes(); |
3943 | Array.Copy(objBytes, 0, bucket, 1, 16); | 4276 | //Array.Copy(objBytes, 0, bucket, 1, 16); |
3944 | 4277 | ||
3945 | GridInstantMessage msg = new GridInstantMessage(World, | 4278 | GridInstantMessage msg = new GridInstantMessage(World, |
3946 | m_host.UUID, m_host.Name+", an object owned by "+ | 4279 | m_host.OwnerID, m_host.Name, destId, |
3947 | resolveName(m_host.OwnerID)+",", destId, | ||
3948 | (byte)InstantMessageDialog.TaskInventoryOffered, | 4280 | (byte)InstantMessageDialog.TaskInventoryOffered, |
3949 | false, objName+"\n"+m_host.Name+" is located at "+ | 4281 | false, objName+". "+m_host.Name+" is located at "+ |
3950 | World.RegionInfo.RegionName+" "+ | 4282 | World.RegionInfo.RegionName+" "+ |
3951 | m_host.AbsolutePosition.ToString(), | 4283 | m_host.AbsolutePosition.ToString(), |
3952 | agentItem.ID, true, m_host.AbsolutePosition, | 4284 | agentItem.ID, true, m_host.AbsolutePosition, |
3953 | bucket); | 4285 | bucket); |
3954 | if (m_TransferModule != null) | 4286 | |
3955 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4287 | ScenePresence sp; |
4288 | |||
4289 | if (World.TryGetScenePresence(destId, out sp)) | ||
4290 | { | ||
4291 | sp.ControllingClient.SendInstantMessage(msg); | ||
4292 | } | ||
4293 | else | ||
4294 | { | ||
4295 | if (m_TransferModule != null) | ||
4296 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | ||
4297 | } | ||
4298 | |||
4299 | //This delay should only occur when giving inventory to avatars. | ||
3956 | ScriptSleep(3000); | 4300 | ScriptSleep(3000); |
3957 | } | 4301 | } |
3958 | } | 4302 | } |
3959 | 4303 | ||
4304 | [DebuggerNonUserCode] | ||
3960 | public void llRemoveInventory(string name) | 4305 | public void llRemoveInventory(string name) |
3961 | { | 4306 | { |
3962 | m_host.AddScriptLPS(1); | 4307 | m_host.AddScriptLPS(1); |
3963 | 4308 | ||
3964 | lock (m_host.TaskInventory) | 4309 | List<TaskInventoryItem> inv; |
4310 | try | ||
3965 | { | 4311 | { |
3966 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4312 | m_host.TaskInventory.LockItemsForRead(true); |
4313 | inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); | ||
4314 | } | ||
4315 | finally | ||
4316 | { | ||
4317 | m_host.TaskInventory.LockItemsForRead(false); | ||
4318 | } | ||
4319 | foreach (TaskInventoryItem item in inv) | ||
4320 | { | ||
4321 | if (item.Name == name) | ||
3967 | { | 4322 | { |
3968 | if (item.Name == name) | 4323 | if (item.ItemID == m_item.ItemID) |
3969 | { | 4324 | throw new ScriptDeleteException(); |
3970 | if (item.ItemID == m_item.ItemID) | 4325 | else |
3971 | throw new ScriptDeleteException(); | 4326 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3972 | else | 4327 | return; |
3973 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
3974 | return; | ||
3975 | } | ||
3976 | } | 4328 | } |
3977 | } | 4329 | } |
3978 | } | 4330 | } |
@@ -4007,115 +4359,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4007 | { | 4359 | { |
4008 | m_host.AddScriptLPS(1); | 4360 | m_host.AddScriptLPS(1); |
4009 | 4361 | ||
4010 | UUID uuid = (UUID)id; | 4362 | UUID uuid; |
4011 | PresenceInfo pinfo = null; | 4363 | if (UUID.TryParse(id, out uuid)) |
4012 | UserAccount account; | ||
4013 | |||
4014 | UserInfoCacheEntry ce; | ||
4015 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
4016 | { | 4364 | { |
4017 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4365 | PresenceInfo pinfo = null; |
4018 | if (account == null) | 4366 | UserAccount account; |
4367 | |||
4368 | UserInfoCacheEntry ce; | ||
4369 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | ||
4019 | { | 4370 | { |
4020 | m_userInfoCache[uuid] = null; // Cache negative | 4371 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
4021 | return UUID.Zero.ToString(); | 4372 | if (account == null) |
4022 | } | 4373 | { |
4374 | m_userInfoCache[uuid] = null; // Cache negative | ||
4375 | return UUID.Zero.ToString(); | ||
4376 | } | ||
4023 | 4377 | ||
4024 | 4378 | ||
4025 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4379 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4026 | if (pinfos != null && pinfos.Length > 0) | 4380 | if (pinfos != null && pinfos.Length > 0) |
4027 | { | ||
4028 | foreach (PresenceInfo p in pinfos) | ||
4029 | { | 4381 | { |
4030 | if (p.RegionID != UUID.Zero) | 4382 | foreach (PresenceInfo p in pinfos) |
4031 | { | 4383 | { |
4032 | pinfo = p; | 4384 | if (p.RegionID != UUID.Zero) |
4385 | { | ||
4386 | pinfo = p; | ||
4387 | } | ||
4033 | } | 4388 | } |
4034 | } | 4389 | } |
4035 | } | ||
4036 | 4390 | ||
4037 | ce = new UserInfoCacheEntry(); | 4391 | ce = new UserInfoCacheEntry(); |
4038 | ce.time = Util.EnvironmentTickCount(); | 4392 | ce.time = Util.EnvironmentTickCount(); |
4039 | ce.account = account; | 4393 | ce.account = account; |
4040 | ce.pinfo = pinfo; | 4394 | ce.pinfo = pinfo; |
4041 | } | 4395 | m_userInfoCache[uuid] = ce; |
4042 | else | 4396 | } |
4043 | { | 4397 | else |
4044 | if (ce == null) | 4398 | { |
4045 | return UUID.Zero.ToString(); | 4399 | if (ce == null) |
4400 | return UUID.Zero.ToString(); | ||
4046 | 4401 | ||
4047 | account = ce.account; | 4402 | account = ce.account; |
4048 | pinfo = ce.pinfo; | 4403 | pinfo = ce.pinfo; |
4049 | } | 4404 | } |
4050 | 4405 | ||
4051 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | 4406 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) |
4052 | { | ||
4053 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | ||
4054 | if (pinfos != null && pinfos.Length > 0) | ||
4055 | { | 4407 | { |
4056 | foreach (PresenceInfo p in pinfos) | 4408 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4409 | if (pinfos != null && pinfos.Length > 0) | ||
4057 | { | 4410 | { |
4058 | if (p.RegionID != UUID.Zero) | 4411 | foreach (PresenceInfo p in pinfos) |
4059 | { | 4412 | { |
4060 | pinfo = p; | 4413 | if (p.RegionID != UUID.Zero) |
4414 | { | ||
4415 | pinfo = p; | ||
4416 | } | ||
4061 | } | 4417 | } |
4062 | } | 4418 | } |
4063 | } | 4419 | else |
4064 | else | 4420 | pinfo = null; |
4065 | pinfo = null; | ||
4066 | 4421 | ||
4067 | ce.time = Util.EnvironmentTickCount(); | 4422 | ce.time = Util.EnvironmentTickCount(); |
4068 | ce.pinfo = pinfo; | 4423 | ce.pinfo = pinfo; |
4069 | } | 4424 | } |
4070 | 4425 | ||
4071 | string reply = String.Empty; | 4426 | string reply = String.Empty; |
4072 | 4427 | ||
4073 | switch (data) | 4428 | switch (data) |
4074 | { | 4429 | { |
4075 | case 1: // DATA_ONLINE (0|1) | 4430 | case 1: // DATA_ONLINE (0|1) |
4076 | if (pinfo != null && pinfo.RegionID != UUID.Zero) | 4431 | if (pinfo != null && pinfo.RegionID != UUID.Zero) |
4077 | reply = "1"; | 4432 | reply = "1"; |
4078 | else | 4433 | else |
4079 | reply = "0"; | 4434 | reply = "0"; |
4080 | break; | 4435 | break; |
4081 | case 2: // DATA_NAME (First Last) | 4436 | case 2: // DATA_NAME (First Last) |
4082 | reply = account.FirstName + " " + account.LastName; | 4437 | reply = account.FirstName + " " + account.LastName; |
4083 | break; | 4438 | break; |
4084 | case 3: // DATA_BORN (YYYY-MM-DD) | 4439 | case 3: // DATA_BORN (YYYY-MM-DD) |
4085 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | 4440 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); |
4086 | born = born.AddSeconds(account.Created); | 4441 | born = born.AddSeconds(account.Created); |
4087 | reply = born.ToString("yyyy-MM-dd"); | 4442 | reply = born.ToString("yyyy-MM-dd"); |
4088 | break; | 4443 | break; |
4089 | case 4: // DATA_RATING (0,0,0,0,0,0) | 4444 | case 4: // DATA_RATING (0,0,0,0,0,0) |
4090 | reply = "0,0,0,0,0,0"; | 4445 | reply = "0,0,0,0,0,0"; |
4091 | break; | 4446 | break; |
4092 | case 7: // DATA_USERLEVEL (integer) | 4447 | case 8: // DATA_PAYINFO (0|1|2|3) |
4093 | reply = account.UserLevel.ToString(); | 4448 | reply = "0"; |
4094 | break; | 4449 | break; |
4095 | case 8: // DATA_PAYINFO (0|1|2|3) | 4450 | default: |
4096 | reply = "0"; | 4451 | return UUID.Zero.ToString(); // Raise no event |
4097 | break; | 4452 | } |
4098 | default: | ||
4099 | return UUID.Zero.ToString(); // Raise no event | ||
4100 | } | ||
4101 | 4453 | ||
4102 | UUID rq = UUID.Random(); | 4454 | UUID rq = UUID.Random(); |
4103 | 4455 | ||
4104 | UUID tid = AsyncCommands. | 4456 | UUID tid = AsyncCommands. |
4105 | DataserverPlugin.RegisterRequest(m_host.LocalId, | 4457 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4106 | m_item.ItemID, rq.ToString()); | 4458 | m_item.ItemID, rq.ToString()); |
4107 | 4459 | ||
4108 | AsyncCommands. | 4460 | AsyncCommands. |
4109 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 4461 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
4110 | 4462 | ||
4111 | ScriptSleep(100); | 4463 | ScriptSleep(100); |
4112 | return tid.ToString(); | 4464 | return tid.ToString(); |
4465 | } | ||
4466 | else | ||
4467 | { | ||
4468 | ShoutError("Invalid UUID passed to llRequestAgentData."); | ||
4469 | } | ||
4470 | return ""; | ||
4113 | } | 4471 | } |
4114 | 4472 | ||
4115 | public LSL_String llRequestInventoryData(string name) | 4473 | public LSL_String llRequestInventoryData(string name) |
4116 | { | 4474 | { |
4117 | m_host.AddScriptLPS(1); | 4475 | m_host.AddScriptLPS(1); |
4118 | 4476 | ||
4477 | //Clone is thread safe | ||
4119 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4478 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
4120 | 4479 | ||
4121 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4480 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4167,19 +4526,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4167 | if (UUID.TryParse(agent, out agentId)) | 4526 | if (UUID.TryParse(agent, out agentId)) |
4168 | { | 4527 | { |
4169 | ScenePresence presence = World.GetScenePresence(agentId); | 4528 | ScenePresence presence = World.GetScenePresence(agentId); |
4170 | if (presence != null) | 4529 | if (presence != null && presence.PresenceType != PresenceType.Npc) |
4171 | { | 4530 | { |
4531 | // agent must not be a god | ||
4532 | if (presence.UserLevel >= 200) return; | ||
4533 | |||
4172 | // agent must be over the owners land | 4534 | // agent must be over the owners land |
4173 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4535 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4174 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4536 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
4175 | { | 4537 | { |
4176 | World.TeleportClientHome(agentId, presence.ControllingClient); | 4538 | if (!World.TeleportClientHome(agentId, presence.ControllingClient)) |
4539 | { | ||
4540 | // They can't be teleported home for some reason | ||
4541 | GridRegion regionInfo = World.GridService.GetRegionByUUID(UUID.Zero, new UUID("2b02daac-e298-42fa-9a75-f488d37896e6")); | ||
4542 | if (regionInfo != null) | ||
4543 | { | ||
4544 | World.RequestTeleportLocation( | ||
4545 | presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero, | ||
4546 | (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); | ||
4547 | } | ||
4548 | } | ||
4177 | } | 4549 | } |
4178 | } | 4550 | } |
4179 | } | 4551 | } |
4180 | ScriptSleep(5000); | 4552 | ScriptSleep(5000); |
4181 | } | 4553 | } |
4182 | 4554 | ||
4555 | public void llTeleportAgent(string agent, string simname, LSL_Vector pos, LSL_Vector lookAt) | ||
4556 | { | ||
4557 | m_host.AddScriptLPS(1); | ||
4558 | UUID agentId = new UUID(); | ||
4559 | if (UUID.TryParse(agent, out agentId)) | ||
4560 | { | ||
4561 | ScenePresence presence = World.GetScenePresence(agentId); | ||
4562 | if (presence != null && presence.PresenceType != PresenceType.Npc) | ||
4563 | { | ||
4564 | // agent must not be a god | ||
4565 | if (presence.GodLevel >= 200) return; | ||
4566 | |||
4567 | if (simname == String.Empty) | ||
4568 | simname = World.RegionInfo.RegionName; | ||
4569 | |||
4570 | // agent must be over the owners land | ||
4571 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | ||
4572 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | ||
4573 | { | ||
4574 | World.RequestTeleportLocation(presence.ControllingClient, simname, new Vector3((float)pos.x, (float)pos.y, (float)pos.z), new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z), (uint)TeleportFlags.ViaLocation); | ||
4575 | } | ||
4576 | else // or must be wearing the prim | ||
4577 | { | ||
4578 | if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) | ||
4579 | { | ||
4580 | World.RequestTeleportLocation(presence.ControllingClient, simname, new Vector3((float)pos.x, (float)pos.y, (float)pos.z), new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z), (uint)TeleportFlags.ViaLocation); | ||
4581 | } | ||
4582 | } | ||
4583 | } | ||
4584 | } | ||
4585 | } | ||
4586 | |||
4183 | public void llTextBox(string agent, string message, int chatChannel) | 4587 | public void llTextBox(string agent, string message, int chatChannel) |
4184 | { | 4588 | { |
4185 | IDialogModule dm = World.RequestModuleInterface<IDialogModule>(); | 4589 | IDialogModule dm = World.RequestModuleInterface<IDialogModule>(); |
@@ -4191,7 +4595,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4191 | UUID av = new UUID(); | 4595 | UUID av = new UUID(); |
4192 | if (!UUID.TryParse(agent,out av)) | 4596 | if (!UUID.TryParse(agent,out av)) |
4193 | { | 4597 | { |
4194 | LSLError("First parameter to llDialog needs to be a key"); | 4598 | //LSLError("First parameter to llDialog needs to be a key"); |
4195 | return; | 4599 | return; |
4196 | } | 4600 | } |
4197 | 4601 | ||
@@ -4223,25 +4627,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4223 | public void llCollisionSound(string impact_sound, double impact_volume) | 4627 | public void llCollisionSound(string impact_sound, double impact_volume) |
4224 | { | 4628 | { |
4225 | m_host.AddScriptLPS(1); | 4629 | m_host.AddScriptLPS(1); |
4226 | 4630 | ||
4631 | if(impact_sound == "") | ||
4632 | { | ||
4633 | m_host.CollisionSoundVolume = (float)impact_volume; | ||
4634 | m_host.CollisionSound = m_host.invalidCollisionSoundUUID; | ||
4635 | return; | ||
4636 | } | ||
4227 | // TODO: Parameter check logic required. | 4637 | // TODO: Parameter check logic required. |
4228 | UUID soundId = UUID.Zero; | 4638 | UUID soundId = UUID.Zero; |
4229 | if (!UUID.TryParse(impact_sound, out soundId)) | 4639 | if (!UUID.TryParse(impact_sound, out soundId)) |
4230 | { | 4640 | { |
4231 | lock (m_host.TaskInventory) | 4641 | m_host.TaskInventory.LockItemsForRead(true); |
4642 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4232 | { | 4643 | { |
4233 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4644 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4234 | { | 4645 | { |
4235 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4646 | soundId = item.AssetID; |
4236 | { | 4647 | break; |
4237 | soundId = item.AssetID; | ||
4238 | break; | ||
4239 | } | ||
4240 | } | 4648 | } |
4241 | } | 4649 | } |
4650 | m_host.TaskInventory.LockItemsForRead(false); | ||
4242 | } | 4651 | } |
4243 | m_host.CollisionSound = soundId; | ||
4244 | m_host.CollisionSoundVolume = (float)impact_volume; | 4652 | m_host.CollisionSoundVolume = (float)impact_volume; |
4653 | m_host.CollisionSound = soundId; | ||
4245 | } | 4654 | } |
4246 | 4655 | ||
4247 | public LSL_String llGetAnimation(string id) | 4656 | public LSL_String llGetAnimation(string id) |
@@ -4278,6 +4687,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4278 | UUID partItemID; | 4687 | UUID partItemID; |
4279 | foreach (SceneObjectPart part in parts) | 4688 | foreach (SceneObjectPart part in parts) |
4280 | { | 4689 | { |
4690 | //Clone is thread safe | ||
4281 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4691 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4282 | 4692 | ||
4283 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4693 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4411,7 +4821,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4411 | { | 4821 | { |
4412 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); | 4822 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); |
4413 | float distance_term = distance * distance * distance; // Script Energy | 4823 | float distance_term = distance * distance * distance; // Script Energy |
4414 | float pusher_mass = m_host.GetMass(); | 4824 | // use total object mass and not part |
4825 | float pusher_mass = m_host.ParentGroup.GetMass(); | ||
4415 | 4826 | ||
4416 | float PUSH_ATTENUATION_DISTANCE = 17f; | 4827 | float PUSH_ATTENUATION_DISTANCE = 17f; |
4417 | float PUSH_ATTENUATION_SCALE = 5f; | 4828 | float PUSH_ATTENUATION_SCALE = 5f; |
@@ -4650,23 +5061,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4650 | { | 5061 | { |
4651 | m_host.AddScriptLPS(1); | 5062 | m_host.AddScriptLPS(1); |
4652 | 5063 | ||
4653 | lock (m_host.TaskInventory) | 5064 | m_host.TaskInventory.LockItemsForRead(true); |
5065 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4654 | { | 5066 | { |
4655 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 5067 | if (inv.Value.Name == name) |
4656 | { | 5068 | { |
4657 | if (inv.Value.Name == name) | 5069 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4658 | { | 5070 | { |
4659 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 5071 | m_host.TaskInventory.LockItemsForRead(false); |
4660 | { | 5072 | return inv.Value.AssetID.ToString(); |
4661 | return inv.Value.AssetID.ToString(); | 5073 | } |
4662 | } | 5074 | else |
4663 | else | 5075 | { |
4664 | { | 5076 | m_host.TaskInventory.LockItemsForRead(false); |
4665 | return UUID.Zero.ToString(); | 5077 | return UUID.Zero.ToString(); |
4666 | } | ||
4667 | } | 5078 | } |
4668 | } | 5079 | } |
4669 | } | 5080 | } |
5081 | m_host.TaskInventory.LockItemsForRead(false); | ||
4670 | 5082 | ||
4671 | return UUID.Zero.ToString(); | 5083 | return UUID.Zero.ToString(); |
4672 | } | 5084 | } |
@@ -4800,7 +5212,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4800 | public LSL_Vector llGetCenterOfMass() | 5212 | public LSL_Vector llGetCenterOfMass() |
4801 | { | 5213 | { |
4802 | m_host.AddScriptLPS(1); | 5214 | m_host.AddScriptLPS(1); |
4803 | Vector3 center = m_host.GetGeometricCenter(); | 5215 | Vector3 center = m_host.GetCenterOfMass(); |
4804 | return new LSL_Vector(center.X,center.Y,center.Z); | 5216 | return new LSL_Vector(center.X,center.Y,center.Z); |
4805 | } | 5217 | } |
4806 | 5218 | ||
@@ -4819,14 +5231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4819 | { | 5231 | { |
4820 | m_host.AddScriptLPS(1); | 5232 | m_host.AddScriptLPS(1); |
4821 | 5233 | ||
4822 | if (src == null) | 5234 | return src.Length; |
4823 | { | ||
4824 | return 0; | ||
4825 | } | ||
4826 | else | ||
4827 | { | ||
4828 | return src.Length; | ||
4829 | } | ||
4830 | } | 5235 | } |
4831 | 5236 | ||
4832 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5237 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -4872,7 +5277,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4872 | else if (src.Data[index] is LSL_Float) | 5277 | else if (src.Data[index] is LSL_Float) |
4873 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); | 5278 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); |
4874 | else if (src.Data[index] is LSL_String) | 5279 | else if (src.Data[index] is LSL_String) |
4875 | return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); | 5280 | { |
5281 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5282 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5283 | if (m != Match.Empty) | ||
5284 | { | ||
5285 | str = m.Value; | ||
5286 | double d = 0.0; | ||
5287 | if (!Double.TryParse(str, out d)) | ||
5288 | return 0.0; | ||
5289 | |||
5290 | return d; | ||
5291 | } | ||
5292 | return 0.0; | ||
5293 | } | ||
4876 | return Convert.ToDouble(src.Data[index]); | 5294 | return Convert.ToDouble(src.Data[index]); |
4877 | } | 5295 | } |
4878 | catch (FormatException) | 5296 | catch (FormatException) |
@@ -5145,7 +5563,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5145 | } | 5563 | } |
5146 | } | 5564 | } |
5147 | } | 5565 | } |
5148 | else { | 5566 | else |
5567 | { | ||
5149 | object[] array = new object[src.Length]; | 5568 | object[] array = new object[src.Length]; |
5150 | Array.Copy(src.Data, 0, array, 0, src.Length); | 5569 | Array.Copy(src.Data, 0, array, 0, src.Length); |
5151 | result = new LSL_List(array); | 5570 | result = new LSL_List(array); |
@@ -5252,7 +5671,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5252 | public LSL_Integer llGetRegionAgentCount() | 5671 | public LSL_Integer llGetRegionAgentCount() |
5253 | { | 5672 | { |
5254 | m_host.AddScriptLPS(1); | 5673 | m_host.AddScriptLPS(1); |
5255 | return new LSL_Integer(World.GetRootAgentCount()); | 5674 | |
5675 | int count = 0; | ||
5676 | World.ForEachRootScenePresence(delegate(ScenePresence sp) { | ||
5677 | count++; | ||
5678 | }); | ||
5679 | |||
5680 | return new LSL_Integer(count); | ||
5256 | } | 5681 | } |
5257 | 5682 | ||
5258 | public LSL_Vector llGetRegionCorner() | 5683 | public LSL_Vector llGetRegionCorner() |
@@ -5532,6 +5957,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5532 | flags |= ScriptBaseClass.AGENT_SITTING; | 5957 | flags |= ScriptBaseClass.AGENT_SITTING; |
5533 | } | 5958 | } |
5534 | 5959 | ||
5960 | if (agent.Appearance.VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MALE] > 0) | ||
5961 | { | ||
5962 | flags |= ScriptBaseClass.AGENT_MALE; | ||
5963 | } | ||
5964 | |||
5535 | return flags; | 5965 | return flags; |
5536 | } | 5966 | } |
5537 | 5967 | ||
@@ -5679,10 +6109,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5679 | m_host.AddScriptLPS(1); | 6109 | m_host.AddScriptLPS(1); |
5680 | 6110 | ||
5681 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6111 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5682 | 6112 | if (parts.Count > 0) | |
5683 | foreach (var part in parts) | ||
5684 | { | 6113 | { |
5685 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 6114 | try |
6115 | { | ||
6116 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
6117 | foreach (var part in parts) | ||
6118 | { | ||
6119 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6120 | } | ||
6121 | } | ||
6122 | finally | ||
6123 | { | ||
6124 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
6125 | } | ||
5686 | } | 6126 | } |
5687 | } | 6127 | } |
5688 | 6128 | ||
@@ -5734,13 +6174,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5734 | 6174 | ||
5735 | if (m_host.OwnerID == land.LandData.OwnerID) | 6175 | if (m_host.OwnerID == land.LandData.OwnerID) |
5736 | { | 6176 | { |
5737 | World.TeleportClientHome(agentID, presence.ControllingClient); | 6177 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6178 | presence.TeleportWithMomentum(pos, null); | ||
6179 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
5738 | } | 6180 | } |
5739 | } | 6181 | } |
5740 | } | 6182 | } |
5741 | ScriptSleep(5000); | 6183 | ScriptSleep(5000); |
5742 | } | 6184 | } |
5743 | 6185 | ||
6186 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
6187 | { | ||
6188 | return ParseString2List(str, separators, in_spacers, false); | ||
6189 | } | ||
6190 | |||
5744 | public LSL_Integer llOverMyLand(string id) | 6191 | public LSL_Integer llOverMyLand(string id) |
5745 | { | 6192 | { |
5746 | m_host.AddScriptLPS(1); | 6193 | m_host.AddScriptLPS(1); |
@@ -5805,8 +6252,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5805 | UUID agentId = new UUID(); | 6252 | UUID agentId = new UUID(); |
5806 | if (!UUID.TryParse(agent, out agentId)) | 6253 | if (!UUID.TryParse(agent, out agentId)) |
5807 | return new LSL_Integer(0); | 6254 | return new LSL_Integer(0); |
6255 | if (agentId == m_host.GroupID) | ||
6256 | return new LSL_Integer(1); | ||
5808 | ScenePresence presence = World.GetScenePresence(agentId); | 6257 | ScenePresence presence = World.GetScenePresence(agentId); |
5809 | if (presence == null || presence.IsChildAgent) // Return flase for child agents | 6258 | if (presence == null || presence.IsChildAgent) // Return false for child agents |
5810 | return new LSL_Integer(0); | 6259 | return new LSL_Integer(0); |
5811 | IClientAPI client = presence.ControllingClient; | 6260 | IClientAPI client = presence.ControllingClient; |
5812 | if (m_host.GroupID == client.ActiveGroupId) | 6261 | if (m_host.GroupID == client.ActiveGroupId) |
@@ -5941,7 +6390,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5941 | return m_host.ParentGroup.AttachmentPoint; | 6390 | return m_host.ParentGroup.AttachmentPoint; |
5942 | } | 6391 | } |
5943 | 6392 | ||
5944 | public LSL_Integer llGetFreeMemory() | 6393 | public virtual LSL_Integer llGetFreeMemory() |
5945 | { | 6394 | { |
5946 | m_host.AddScriptLPS(1); | 6395 | m_host.AddScriptLPS(1); |
5947 | // Make scripts designed for LSO happy | 6396 | // Make scripts designed for LSO happy |
@@ -6058,7 +6507,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6058 | SetParticleSystem(m_host, rules); | 6507 | SetParticleSystem(m_host, rules); |
6059 | } | 6508 | } |
6060 | 6509 | ||
6061 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { | 6510 | private void SetParticleSystem(SceneObjectPart part, LSL_List rules) |
6511 | { | ||
6062 | 6512 | ||
6063 | 6513 | ||
6064 | if (rules.Length == 0) | 6514 | if (rules.Length == 0) |
@@ -6252,14 +6702,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6252 | 6702 | ||
6253 | protected UUID GetTaskInventoryItem(string name) | 6703 | protected UUID GetTaskInventoryItem(string name) |
6254 | { | 6704 | { |
6255 | lock (m_host.TaskInventory) | 6705 | m_host.TaskInventory.LockItemsForRead(true); |
6706 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6256 | { | 6707 | { |
6257 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6708 | if (inv.Value.Name == name) |
6258 | { | 6709 | { |
6259 | if (inv.Value.Name == name) | 6710 | m_host.TaskInventory.LockItemsForRead(false); |
6260 | return inv.Key; | 6711 | return inv.Key; |
6261 | } | 6712 | } |
6262 | } | 6713 | } |
6714 | m_host.TaskInventory.LockItemsForRead(false); | ||
6263 | 6715 | ||
6264 | return UUID.Zero; | 6716 | return UUID.Zero; |
6265 | } | 6717 | } |
@@ -6297,16 +6749,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6297 | if (folderID == UUID.Zero) | 6749 | if (folderID == UUID.Zero) |
6298 | return; | 6750 | return; |
6299 | 6751 | ||
6300 | byte[] bucket = new byte[17]; | 6752 | byte[] bucket = new byte[1]; |
6301 | bucket[0] = (byte)AssetType.Folder; | 6753 | bucket[0] = (byte)AssetType.Folder; |
6302 | byte[] objBytes = folderID.GetBytes(); | 6754 | //byte[] objBytes = folderID.GetBytes(); |
6303 | Array.Copy(objBytes, 0, bucket, 1, 16); | 6755 | //Array.Copy(objBytes, 0, bucket, 1, 16); |
6304 | 6756 | ||
6305 | GridInstantMessage msg = new GridInstantMessage(World, | 6757 | GridInstantMessage msg = new GridInstantMessage(World, |
6306 | m_host.UUID, m_host.Name+", an object owned by "+ | 6758 | m_host.OwnerID, m_host.Name, destID, |
6307 | resolveName(m_host.OwnerID)+",", destID, | 6759 | (byte)InstantMessageDialog.TaskInventoryOffered, |
6308 | (byte)InstantMessageDialog.InventoryOffered, | 6760 | false, category+". "+m_host.Name+" is located at "+ |
6309 | false, category+"\n"+m_host.Name+" is located at "+ | ||
6310 | World.RegionInfo.RegionName+" "+ | 6761 | World.RegionInfo.RegionName+" "+ |
6311 | m_host.AbsolutePosition.ToString(), | 6762 | m_host.AbsolutePosition.ToString(), |
6312 | folderID, true, m_host.AbsolutePosition, | 6763 | folderID, true, m_host.AbsolutePosition, |
@@ -6544,13 +6995,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6544 | UUID av = new UUID(); | 6995 | UUID av = new UUID(); |
6545 | if (!UUID.TryParse(avatar,out av)) | 6996 | if (!UUID.TryParse(avatar,out av)) |
6546 | { | 6997 | { |
6547 | LSLError("First parameter to llDialog needs to be a key"); | 6998 | //LSLError("First parameter to llDialog needs to be a key"); |
6548 | return; | 6999 | return; |
6549 | } | 7000 | } |
6550 | if (buttons.Length < 1) | 7001 | if (buttons.Length < 1) |
6551 | { | 7002 | { |
6552 | LSLError("No less than 1 button can be shown"); | 7003 | buttons.Add("OK"); |
6553 | return; | ||
6554 | } | 7004 | } |
6555 | if (buttons.Length > 12) | 7005 | if (buttons.Length > 12) |
6556 | { | 7006 | { |
@@ -6567,7 +7017,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6567 | } | 7017 | } |
6568 | if (buttons.Data[i].ToString().Length > 24) | 7018 | if (buttons.Data[i].ToString().Length > 24) |
6569 | { | 7019 | { |
6570 | LSLError("button label cannot be longer than 24 characters"); | 7020 | llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters"); |
6571 | return; | 7021 | return; |
6572 | } | 7022 | } |
6573 | buts[i] = buttons.Data[i].ToString(); | 7023 | buts[i] = buttons.Data[i].ToString(); |
@@ -6626,22 +7076,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6626 | } | 7076 | } |
6627 | 7077 | ||
6628 | // copy the first script found with this inventory name | 7078 | // copy the first script found with this inventory name |
6629 | lock (m_host.TaskInventory) | 7079 | TaskInventoryItem scriptItem = null; |
7080 | m_host.TaskInventory.LockItemsForRead(true); | ||
7081 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6630 | { | 7082 | { |
6631 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 7083 | if (inv.Value.Name == name) |
6632 | { | 7084 | { |
6633 | if (inv.Value.Name == name) | 7085 | // make sure the object is a script |
7086 | if (10 == inv.Value.Type) | ||
6634 | { | 7087 | { |
6635 | // make sure the object is a script | 7088 | found = true; |
6636 | if (10 == inv.Value.Type) | 7089 | srcId = inv.Key; |
6637 | { | 7090 | scriptItem = inv.Value; |
6638 | found = true; | 7091 | break; |
6639 | srcId = inv.Key; | ||
6640 | break; | ||
6641 | } | ||
6642 | } | 7092 | } |
6643 | } | 7093 | } |
6644 | } | 7094 | } |
7095 | m_host.TaskInventory.LockItemsForRead(false); | ||
6645 | 7096 | ||
6646 | if (!found) | 7097 | if (!found) |
6647 | { | 7098 | { |
@@ -6649,9 +7100,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6649 | return; | 7100 | return; |
6650 | } | 7101 | } |
6651 | 7102 | ||
6652 | // the rest of the permission checks are done in RezScript, so check the pin there as well | 7103 | SceneObjectPart dest = World.GetSceneObjectPart(destId); |
6653 | World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); | 7104 | if (dest != null) |
7105 | { | ||
7106 | if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) | ||
7107 | { | ||
7108 | // the rest of the permission checks are done in RezScript, so check the pin there as well | ||
7109 | World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); | ||
6654 | 7110 | ||
7111 | if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0) | ||
7112 | m_host.Inventory.RemoveInventoryItem(srcId); | ||
7113 | } | ||
7114 | } | ||
6655 | // this will cause the delay even if the script pin or permissions were wrong - seems ok | 7115 | // this will cause the delay even if the script pin or permissions were wrong - seems ok |
6656 | ScriptSleep(3000); | 7116 | ScriptSleep(3000); |
6657 | } | 7117 | } |
@@ -6714,19 +7174,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6714 | public LSL_String llMD5String(string src, int nonce) | 7174 | public LSL_String llMD5String(string src, int nonce) |
6715 | { | 7175 | { |
6716 | m_host.AddScriptLPS(1); | 7176 | m_host.AddScriptLPS(1); |
6717 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); | 7177 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); |
6718 | } | 7178 | } |
6719 | 7179 | ||
6720 | public LSL_String llSHA1String(string src) | 7180 | public LSL_String llSHA1String(string src) |
6721 | { | 7181 | { |
6722 | m_host.AddScriptLPS(1); | 7182 | m_host.AddScriptLPS(1); |
6723 | return Util.SHA1Hash(src).ToLower(); | 7183 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
6724 | } | 7184 | } |
6725 | 7185 | ||
6726 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) | 7186 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) |
6727 | { | 7187 | { |
6728 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7188 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
6729 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7189 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7190 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7191 | return shapeBlock; | ||
6730 | 7192 | ||
6731 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 7193 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6732 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 7194 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6831,6 +7293,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6831 | // Prim type box, cylinder and prism. | 7293 | // Prim type box, cylinder and prism. |
6832 | 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) | 7294 | 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) |
6833 | { | 7295 | { |
7296 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7297 | return; | ||
7298 | |||
6834 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7299 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
6835 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7300 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6836 | 7301 | ||
@@ -6884,6 +7349,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6884 | // Prim type sphere. | 7349 | // Prim type sphere. |
6885 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) | 7350 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) |
6886 | { | 7351 | { |
7352 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7353 | return; | ||
7354 | |||
6887 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7355 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6888 | 7356 | ||
6889 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); | 7357 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
@@ -6925,6 +7393,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6925 | // Prim type torus, tube and ring. | 7393 | // Prim type torus, tube and ring. |
6926 | 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) | 7394 | 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) |
6927 | { | 7395 | { |
7396 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7397 | return; | ||
7398 | |||
6928 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 7399 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
6929 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7400 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6930 | 7401 | ||
@@ -7060,6 +7531,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7060 | // Prim type sculpt. | 7531 | // Prim type sculpt. |
7061 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) | 7532 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) |
7062 | { | 7533 | { |
7534 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7535 | return; | ||
7536 | |||
7063 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7537 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7064 | UUID sculptId; | 7538 | UUID sculptId; |
7065 | 7539 | ||
@@ -7084,7 +7558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7084 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) | 7558 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) |
7085 | { | 7559 | { |
7086 | // default | 7560 | // default |
7087 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7561 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
7088 | } | 7562 | } |
7089 | 7563 | ||
7090 | part.Shape.SetSculptProperties((byte)type, sculptId); | 7564 | part.Shape.SetSculptProperties((byte)type, sculptId); |
@@ -7100,32 +7574,149 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7100 | ScriptSleep(200); | 7574 | ScriptSleep(200); |
7101 | } | 7575 | } |
7102 | 7576 | ||
7103 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7577 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
7104 | { | 7578 | { |
7105 | m_host.AddScriptLPS(1); | 7579 | m_host.AddScriptLPS(1); |
7106 | 7580 | ||
7107 | setLinkPrimParams(linknumber, rules); | 7581 | setLinkPrimParams(linknumber, rules); |
7582 | } | ||
7108 | 7583 | ||
7109 | ScriptSleep(200); | 7584 | private void setLinkPrimParams(int linknumber, LSL_List rules) |
7585 | { | ||
7586 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | ||
7587 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
7588 | if (parts.Count>0) | ||
7589 | { | ||
7590 | try | ||
7591 | { | ||
7592 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7593 | foreach (SceneObjectPart part in parts) | ||
7594 | SetPrimParams(part, rules); | ||
7595 | } | ||
7596 | finally | ||
7597 | { | ||
7598 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7599 | } | ||
7600 | } | ||
7601 | if (avatars.Count > 0) | ||
7602 | { | ||
7603 | foreach (ScenePresence avatar in avatars) | ||
7604 | SetPrimParams(avatar, rules); | ||
7605 | } | ||
7110 | } | 7606 | } |
7111 | 7607 | ||
7112 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7608 | private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, |
7609 | float material_density, float material_friction, | ||
7610 | float material_restitution, float material_gravity_modifier) | ||
7113 | { | 7611 | { |
7114 | m_host.AddScriptLPS(1); | 7612 | ExtraPhysicsData physdata = new ExtraPhysicsData(); |
7613 | physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType; | ||
7614 | physdata.Density = part.Density; | ||
7615 | physdata.Friction = part.Friction; | ||
7616 | physdata.Bounce = part.Bounciness; | ||
7617 | physdata.GravitationModifier = part.GravityModifier; | ||
7115 | 7618 | ||
7116 | setLinkPrimParams(linknumber, rules); | 7619 | if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0) |
7620 | physdata.Density = material_density; | ||
7621 | if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0) | ||
7622 | physdata.Friction = material_friction; | ||
7623 | if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0) | ||
7624 | physdata.Bounce = material_restitution; | ||
7625 | if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0) | ||
7626 | physdata.GravitationModifier = material_gravity_modifier; | ||
7627 | |||
7628 | part.UpdateExtraPhysics(physdata); | ||
7117 | } | 7629 | } |
7118 | 7630 | ||
7119 | protected void setLinkPrimParams(int linknumber, LSL_List rules) | 7631 | public void llSetPhysicsMaterial(int material_bits, |
7632 | float material_gravity_modifier, float material_restitution, | ||
7633 | float material_friction, float material_density) | ||
7120 | { | 7634 | { |
7121 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7635 | SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); |
7636 | } | ||
7122 | 7637 | ||
7123 | foreach (SceneObjectPart part in parts) | 7638 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
7124 | SetPrimParams(part, rules); | 7639 | { |
7640 | llSetLinkPrimitiveParamsFast(linknumber, rules); | ||
7641 | ScriptSleep(200); | ||
7642 | } | ||
7643 | |||
7644 | protected void SetPrimParams(ScenePresence av, LSL_List rules) | ||
7645 | { | ||
7646 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | ||
7647 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
7648 | |||
7649 | int idx = 0; | ||
7650 | |||
7651 | while (idx < rules.Length) | ||
7652 | { | ||
7653 | int code = rules.GetLSLIntegerItem(idx++); | ||
7654 | |||
7655 | int remain = rules.Length - idx; | ||
7656 | |||
7657 | switch (code) | ||
7658 | { | ||
7659 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7660 | { | ||
7661 | if (remain < 1) | ||
7662 | return; | ||
7663 | LSL_Vector v; | ||
7664 | v = rules.GetVector3Item(idx++); | ||
7665 | |||
7666 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7667 | if (part == null) | ||
7668 | break; | ||
7669 | |||
7670 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7671 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7672 | if (llGetLinkNumber() > 1) | ||
7673 | { | ||
7674 | localRot = llGetLocalRot(); | ||
7675 | localPos = llGetLocalPos(); | ||
7676 | } | ||
7677 | |||
7678 | v -= localPos; | ||
7679 | v /= localRot; | ||
7680 | |||
7681 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
7682 | |||
7683 | v = v + 2 * sitOffset; | ||
7684 | |||
7685 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7686 | av.SendAvatarDataToAllAgents(); | ||
7687 | |||
7688 | } | ||
7689 | break; | ||
7690 | |||
7691 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7692 | { | ||
7693 | if (remain < 1) | ||
7694 | return; | ||
7695 | |||
7696 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7697 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7698 | if (llGetLinkNumber() > 1) | ||
7699 | { | ||
7700 | localRot = llGetLocalRot(); | ||
7701 | localPos = llGetLocalPos(); | ||
7702 | } | ||
7703 | |||
7704 | LSL_Rotation r; | ||
7705 | r = rules.GetQuaternionItem(idx++); | ||
7706 | r = r * llGetRootRotation() / localRot; | ||
7707 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7708 | av.SendAvatarDataToAllAgents(); | ||
7709 | } | ||
7710 | break; | ||
7711 | } | ||
7712 | } | ||
7125 | } | 7713 | } |
7126 | 7714 | ||
7127 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7715 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
7128 | { | 7716 | { |
7717 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7718 | return; | ||
7719 | |||
7129 | int idx = 0; | 7720 | int idx = 0; |
7130 | 7721 | ||
7131 | bool positionChanged = false; | 7722 | bool positionChanged = false; |
@@ -7447,6 +8038,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7447 | part.ScriptSetPhysicsStatus(physics); | 8038 | part.ScriptSetPhysicsStatus(physics); |
7448 | break; | 8039 | break; |
7449 | 8040 | ||
8041 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
8042 | if (remain < 1) | ||
8043 | return; | ||
8044 | |||
8045 | int shape_type = rules.GetLSLIntegerItem(idx++); | ||
8046 | |||
8047 | ExtraPhysicsData physdata = new ExtraPhysicsData(); | ||
8048 | physdata.Density = part.Density; | ||
8049 | physdata.Bounce = part.Bounciness; | ||
8050 | physdata.GravitationModifier = part.GravityModifier; | ||
8051 | physdata.PhysShapeType = (PhysShapeType)shape_type; | ||
8052 | |||
8053 | part.UpdateExtraPhysics(physdata); | ||
8054 | |||
8055 | break; | ||
8056 | |||
8057 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
8058 | if (remain < 5) | ||
8059 | return; | ||
8060 | |||
8061 | int material_bits = rules.GetLSLIntegerItem(idx++); | ||
8062 | float material_density = (float)rules.GetLSLFloatItem(idx++); | ||
8063 | float material_friction = (float)rules.GetLSLFloatItem(idx++); | ||
8064 | float material_restitution = (float)rules.GetLSLFloatItem(idx++); | ||
8065 | float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++); | ||
8066 | |||
8067 | SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); | ||
8068 | |||
8069 | break; | ||
8070 | |||
7450 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | 8071 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: |
7451 | if (remain < 1) | 8072 | if (remain < 1) |
7452 | return; | 8073 | return; |
@@ -7520,7 +8141,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7520 | if (part.ParentGroup.RootPart == part) | 8141 | if (part.ParentGroup.RootPart == part) |
7521 | { | 8142 | { |
7522 | SceneObjectGroup parent = part.ParentGroup; | 8143 | SceneObjectGroup parent = part.ParentGroup; |
7523 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | 8144 | Util.FireAndForget(delegate(object x) { |
8145 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | ||
8146 | }); | ||
7524 | } | 8147 | } |
7525 | else | 8148 | else |
7526 | { | 8149 | { |
@@ -7531,6 +8154,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7531 | } | 8154 | } |
7532 | } | 8155 | } |
7533 | } | 8156 | } |
8157 | |||
8158 | if (positionChanged) | ||
8159 | { | ||
8160 | if (part.ParentGroup.RootPart == part) | ||
8161 | { | ||
8162 | SceneObjectGroup parent = part.ParentGroup; | ||
8163 | Util.FireAndForget(delegate(object x) { | ||
8164 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | ||
8165 | }); | ||
8166 | } | ||
8167 | else | ||
8168 | { | ||
8169 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | ||
8170 | SceneObjectGroup parent = part.ParentGroup; | ||
8171 | parent.HasGroupChanged = true; | ||
8172 | parent.ScheduleGroupForTerseUpdate(); | ||
8173 | } | ||
8174 | } | ||
7534 | } | 8175 | } |
7535 | 8176 | ||
7536 | public LSL_String llStringToBase64(string str) | 8177 | public LSL_String llStringToBase64(string str) |
@@ -7691,13 +8332,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7691 | public LSL_Integer llGetNumberOfPrims() | 8332 | public LSL_Integer llGetNumberOfPrims() |
7692 | { | 8333 | { |
7693 | m_host.AddScriptLPS(1); | 8334 | m_host.AddScriptLPS(1); |
7694 | int avatarCount = 0; | 8335 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; |
7695 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | 8336 | |
7696 | { | ||
7697 | if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID)) | ||
7698 | avatarCount++; | ||
7699 | }); | ||
7700 | |||
7701 | return m_host.ParentGroup.PrimCount + avatarCount; | 8337 | return m_host.ParentGroup.PrimCount + avatarCount; |
7702 | } | 8338 | } |
7703 | 8339 | ||
@@ -7713,55 +8349,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7713 | m_host.AddScriptLPS(1); | 8349 | m_host.AddScriptLPS(1); |
7714 | UUID objID = UUID.Zero; | 8350 | UUID objID = UUID.Zero; |
7715 | LSL_List result = new LSL_List(); | 8351 | LSL_List result = new LSL_List(); |
8352 | |||
8353 | // If the ID is not valid, return null result | ||
7716 | if (!UUID.TryParse(obj, out objID)) | 8354 | if (!UUID.TryParse(obj, out objID)) |
7717 | { | 8355 | { |
7718 | result.Add(new LSL_Vector()); | 8356 | result.Add(new LSL_Vector()); |
7719 | result.Add(new LSL_Vector()); | 8357 | result.Add(new LSL_Vector()); |
7720 | return result; | 8358 | return result; |
7721 | } | 8359 | } |
8360 | |||
8361 | // Check if this is an attached prim. If so, replace | ||
8362 | // the UUID with the avatar UUID and report it's bounding box | ||
8363 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
8364 | if (part != null && part.ParentGroup.IsAttachment) | ||
8365 | objID = part.ParentGroup.AttachedAvatar; | ||
8366 | |||
8367 | // Find out if this is an avatar ID. If so, return it's box | ||
7722 | ScenePresence presence = World.GetScenePresence(objID); | 8368 | ScenePresence presence = World.GetScenePresence(objID); |
7723 | if (presence != null) | 8369 | if (presence != null) |
7724 | { | 8370 | { |
7725 | if (presence.ParentID == 0) // not sat on an object | 8371 | // As per LSL Wiki, there is no difference between sitting |
8372 | // and standing avatar since server 1.36 | ||
8373 | LSL_Vector lower; | ||
8374 | LSL_Vector upper; | ||
8375 | if (presence.Animator.Animations.DefaultAnimation.AnimID | ||
8376 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
7726 | { | 8377 | { |
7727 | LSL_Vector lower; | 8378 | // This is for ground sitting avatars |
7728 | LSL_Vector upper; | 8379 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7729 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 8380 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7730 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 8381 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7731 | { | ||
7732 | // This is for ground sitting avatars | ||
7733 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
7734 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
7735 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
7736 | } | ||
7737 | else | ||
7738 | { | ||
7739 | // This is for standing/flying avatars | ||
7740 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
7741 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
7742 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
7743 | } | ||
7744 | result.Add(lower); | ||
7745 | result.Add(upper); | ||
7746 | return result; | ||
7747 | } | 8382 | } |
7748 | else | 8383 | else |
7749 | { | 8384 | { |
7750 | // sitting on an object so we need the bounding box of that | 8385 | // This is for standing/flying avatars |
7751 | // which should include the avatar so set the UUID to the | 8386 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7752 | // UUID of the object the avatar is sat on and allow it to fall through | 8387 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7753 | // to processing an object | 8388 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7754 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7755 | objID = p.UUID; | ||
7756 | } | 8389 | } |
8390 | |||
8391 | // Adjust to the documented error offsets (see LSL Wiki) | ||
8392 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
8393 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
8394 | |||
8395 | if (lower.x > upper.x) | ||
8396 | lower.x = upper.x; | ||
8397 | if (lower.y > upper.y) | ||
8398 | lower.y = upper.y; | ||
8399 | if (lower.z > upper.z) | ||
8400 | lower.z = upper.z; | ||
8401 | |||
8402 | result.Add(lower); | ||
8403 | result.Add(upper); | ||
8404 | return result; | ||
7757 | } | 8405 | } |
7758 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 8406 | |
8407 | part = World.GetSceneObjectPart(objID); | ||
7759 | // Currently only works for single prims without a sitting avatar | 8408 | // Currently only works for single prims without a sitting avatar |
7760 | if (part != null) | 8409 | if (part != null) |
7761 | { | 8410 | { |
7762 | Vector3 halfSize = part.Scale / 2.0f; | 8411 | float minX; |
7763 | LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); | 8412 | float maxX; |
7764 | LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); | 8413 | float minY; |
8414 | float maxY; | ||
8415 | float minZ; | ||
8416 | float maxZ; | ||
8417 | |||
8418 | // This BBox is in sim coordinates, with the offset being | ||
8419 | // a contained point. | ||
8420 | Vector3[] offsets = Scene.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
8421 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
8422 | |||
8423 | minX -= offsets[0].X; | ||
8424 | maxX -= offsets[0].X; | ||
8425 | minY -= offsets[0].Y; | ||
8426 | maxY -= offsets[0].Y; | ||
8427 | minZ -= offsets[0].Z; | ||
8428 | maxZ -= offsets[0].Z; | ||
8429 | |||
8430 | LSL_Vector lower; | ||
8431 | LSL_Vector upper; | ||
8432 | |||
8433 | // Adjust to the documented error offsets (see LSL Wiki) | ||
8434 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
8435 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
8436 | |||
8437 | if (lower.x > upper.x) | ||
8438 | lower.x = upper.x; | ||
8439 | if (lower.y > upper.y) | ||
8440 | lower.y = upper.y; | ||
8441 | if (lower.z > upper.z) | ||
8442 | lower.z = upper.z; | ||
8443 | |||
7765 | result.Add(lower); | 8444 | result.Add(lower); |
7766 | result.Add(upper); | 8445 | result.Add(upper); |
7767 | return result; | 8446 | return result; |
@@ -7775,7 +8454,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7775 | 8454 | ||
7776 | public LSL_Vector llGetGeometricCenter() | 8455 | public LSL_Vector llGetGeometricCenter() |
7777 | { | 8456 | { |
7778 | return new LSL_Vector(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z); | 8457 | Vector3 tmp = m_host.GetGeometricCenter(); |
8458 | return new LSL_Vector(tmp.X, tmp.Y, tmp.Z); | ||
7779 | } | 8459 | } |
7780 | 8460 | ||
7781 | public LSL_List llGetPrimitiveParams(LSL_List rules) | 8461 | public LSL_List llGetPrimitiveParams(LSL_List rules) |
@@ -7841,13 +8521,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7841 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, | 8521 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, |
7842 | part.AbsolutePosition.Y, | 8522 | part.AbsolutePosition.Y, |
7843 | part.AbsolutePosition.Z); | 8523 | part.AbsolutePosition.Z); |
7844 | // For some reason, the part.AbsolutePosition.* values do not change if the | ||
7845 | // linkset is rotated; they always reflect the child prim's world position | ||
7846 | // as though the linkset is unrotated. This is incompatible behavior with SL's | ||
7847 | // implementation, so will break scripts imported from there (not to mention it | ||
7848 | // makes it more difficult to determine a child prim's actual inworld position). | ||
7849 | if (part.ParentID != 0) | ||
7850 | v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition(); | ||
7851 | res.Add(v); | 8524 | res.Add(v); |
7852 | break; | 8525 | break; |
7853 | 8526 | ||
@@ -8018,56 +8691,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8018 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8691 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
8019 | if (remain < 1) | 8692 | if (remain < 1) |
8020 | return res; | 8693 | return res; |
8021 | 8694 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8022 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8023 | 8695 | ||
8024 | tex = part.Shape.Textures; | 8696 | tex = part.Shape.Textures; |
8697 | int shiny; | ||
8025 | if (face == ScriptBaseClass.ALL_SIDES) | 8698 | if (face == ScriptBaseClass.ALL_SIDES) |
8026 | { | 8699 | { |
8027 | for (face = 0; face < GetNumberOfSides(part); face++) | 8700 | for (face = 0; face < GetNumberOfSides(part); face++) |
8028 | { | 8701 | { |
8029 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8702 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
8030 | // Convert Shininess to PRIM_SHINY_* | 8703 | if (shinyness == Shininess.High) |
8031 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 8704 | { |
8032 | // PRIM_BUMP_* | 8705 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
8033 | res.Add(new LSL_Integer((int)texface.Bump)); | 8706 | } |
8707 | else if (shinyness == Shininess.Medium) | ||
8708 | { | ||
8709 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8710 | } | ||
8711 | else if (shinyness == Shininess.Low) | ||
8712 | { | ||
8713 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8714 | } | ||
8715 | else | ||
8716 | { | ||
8717 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8718 | } | ||
8719 | res.Add(new LSL_Integer(shiny)); | ||
8720 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8034 | } | 8721 | } |
8035 | } | 8722 | } |
8036 | else | 8723 | else |
8037 | { | 8724 | { |
8038 | if (face >= 0 && face < GetNumberOfSides(part)) | 8725 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
8726 | if (shinyness == Shininess.High) | ||
8039 | { | 8727 | { |
8040 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8728 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
8041 | // Convert Shininess to PRIM_SHINY_* | 8729 | } |
8042 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 8730 | else if (shinyness == Shininess.Medium) |
8043 | // PRIM_BUMP_* | 8731 | { |
8044 | res.Add(new LSL_Integer((int)texface.Bump)); | 8732 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; |
8733 | } | ||
8734 | else if (shinyness == Shininess.Low) | ||
8735 | { | ||
8736 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8045 | } | 8737 | } |
8738 | else | ||
8739 | { | ||
8740 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8741 | } | ||
8742 | res.Add(new LSL_Integer(shiny)); | ||
8743 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8046 | } | 8744 | } |
8047 | break; | 8745 | break; |
8048 | 8746 | ||
8049 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8747 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
8050 | if (remain < 1) | 8748 | if (remain < 1) |
8051 | return res; | 8749 | return res; |
8052 | 8750 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8053 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8054 | 8751 | ||
8055 | tex = part.Shape.Textures; | 8752 | tex = part.Shape.Textures; |
8753 | int fullbright; | ||
8056 | if (face == ScriptBaseClass.ALL_SIDES) | 8754 | if (face == ScriptBaseClass.ALL_SIDES) |
8057 | { | 8755 | { |
8058 | for (face = 0; face < GetNumberOfSides(part); face++) | 8756 | for (face = 0; face < GetNumberOfSides(part); face++) |
8059 | { | 8757 | { |
8060 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8758 | if (tex.GetFace((uint)face).Fullbright == true) |
8061 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 8759 | { |
8760 | fullbright = ScriptBaseClass.TRUE; | ||
8761 | } | ||
8762 | else | ||
8763 | { | ||
8764 | fullbright = ScriptBaseClass.FALSE; | ||
8765 | } | ||
8766 | res.Add(new LSL_Integer(fullbright)); | ||
8062 | } | 8767 | } |
8063 | } | 8768 | } |
8064 | else | 8769 | else |
8065 | { | 8770 | { |
8066 | if (face >= 0 && face < GetNumberOfSides(part)) | 8771 | if (tex.GetFace((uint)face).Fullbright == true) |
8067 | { | 8772 | { |
8068 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8773 | fullbright = ScriptBaseClass.TRUE; |
8069 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 8774 | } |
8775 | else | ||
8776 | { | ||
8777 | fullbright = ScriptBaseClass.FALSE; | ||
8070 | } | 8778 | } |
8779 | res.Add(new LSL_Integer(fullbright)); | ||
8071 | } | 8780 | } |
8072 | break; | 8781 | break; |
8073 | 8782 | ||
@@ -8089,27 +8798,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8089 | break; | 8798 | break; |
8090 | 8799 | ||
8091 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8800 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
8801 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
8092 | if (remain < 1) | 8802 | if (remain < 1) |
8093 | return res; | 8803 | return res; |
8094 | 8804 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8095 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8096 | 8805 | ||
8097 | tex = part.Shape.Textures; | 8806 | tex = part.Shape.Textures; |
8098 | if (face == ScriptBaseClass.ALL_SIDES) | 8807 | if (face == ScriptBaseClass.ALL_SIDES) |
8099 | { | 8808 | { |
8100 | for (face = 0; face < GetNumberOfSides(part); face++) | 8809 | for (face = 0; face < GetNumberOfSides(part); face++) |
8101 | { | 8810 | { |
8102 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 8811 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
8103 | // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. | 8812 | { |
8104 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 8813 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
8814 | } | ||
8815 | else | ||
8816 | { | ||
8817 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8818 | } | ||
8105 | } | 8819 | } |
8106 | } | 8820 | } |
8107 | else | 8821 | else |
8108 | { | 8822 | { |
8109 | if (face >= 0 && face < GetNumberOfSides(part)) | 8823 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
8824 | { | ||
8825 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8826 | } | ||
8827 | else | ||
8110 | { | 8828 | { |
8111 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 8829 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); |
8112 | res.Add(new LSL_Integer((uint)texgen >> 1)); | ||
8113 | } | 8830 | } |
8114 | } | 8831 | } |
8115 | break; | 8832 | break; |
@@ -8132,28 +8849,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8132 | case (int)ScriptBaseClass.PRIM_GLOW: | 8849 | case (int)ScriptBaseClass.PRIM_GLOW: |
8133 | if (remain < 1) | 8850 | if (remain < 1) |
8134 | return res; | 8851 | return res; |
8135 | 8852 | face = (int)rules.GetLSLIntegerItem(idx++); | |
8136 | face=(int)rules.GetLSLIntegerItem(idx++); | ||
8137 | 8853 | ||
8138 | tex = part.Shape.Textures; | 8854 | tex = part.Shape.Textures; |
8855 | float primglow; | ||
8139 | if (face == ScriptBaseClass.ALL_SIDES) | 8856 | if (face == ScriptBaseClass.ALL_SIDES) |
8140 | { | 8857 | { |
8141 | for (face = 0; face < GetNumberOfSides(part); face++) | 8858 | for (face = 0; face < GetNumberOfSides(part); face++) |
8142 | { | 8859 | { |
8143 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 8860 | primglow = tex.GetFace((uint)face).Glow; |
8144 | res.Add(new LSL_Float(texface.Glow)); | 8861 | res.Add(new LSL_Float(primglow)); |
8145 | } | 8862 | } |
8146 | } | 8863 | } |
8147 | else | 8864 | else |
8148 | { | 8865 | { |
8149 | if (face >= 0 && face < GetNumberOfSides(part)) | 8866 | primglow = tex.GetFace((uint)face).Glow; |
8150 | { | 8867 | res.Add(new LSL_Float(primglow)); |
8151 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
8152 | res.Add(new LSL_Float(texface.Glow)); | ||
8153 | } | ||
8154 | } | 8868 | } |
8155 | break; | 8869 | break; |
8156 | |||
8157 | case (int)ScriptBaseClass.PRIM_TEXT: | 8870 | case (int)ScriptBaseClass.PRIM_TEXT: |
8158 | Color4 textColor = part.GetTextColor(); | 8871 | Color4 textColor = part.GetTextColor(); |
8159 | res.Add(new LSL_String(part.Text)); | 8872 | res.Add(new LSL_String(part.Text)); |
@@ -8765,8 +9478,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8765 | // The function returns an ordered list | 9478 | // The function returns an ordered list |
8766 | // representing the tokens found in the supplied | 9479 | // representing the tokens found in the supplied |
8767 | // sources string. If two successive tokenizers | 9480 | // sources string. If two successive tokenizers |
8768 | // are encountered, then a NULL entry is added | 9481 | // are encountered, then a null-string entry is |
8769 | // to the list. | 9482 | // added to the list. |
8770 | // | 9483 | // |
8771 | // It is a precondition that the source and | 9484 | // It is a precondition that the source and |
8772 | // toekizer lisst are non-null. If they are null, | 9485 | // toekizer lisst are non-null. If they are null, |
@@ -8774,7 +9487,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8774 | // while their lengths are being determined. | 9487 | // while their lengths are being determined. |
8775 | // | 9488 | // |
8776 | // A small amount of working memoryis required | 9489 | // A small amount of working memoryis required |
8777 | // of approximately 8*#tokenizers. | 9490 | // of approximately 8*#tokenizers + 8*srcstrlen. |
8778 | // | 9491 | // |
8779 | // There are many ways in which this function | 9492 | // There are many ways in which this function |
8780 | // can be implemented, this implementation is | 9493 | // can be implemented, this implementation is |
@@ -8790,155 +9503,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8790 | // and eliminates redundant tokenizers as soon | 9503 | // and eliminates redundant tokenizers as soon |
8791 | // as is possible. | 9504 | // as is possible. |
8792 | // | 9505 | // |
8793 | // The implementation tries to avoid any copying | 9506 | // The implementation tries to minimize temporary |
8794 | // of arrays or other objects. | 9507 | // garbage generation. |
8795 | // </remarks> | 9508 | // </remarks> |
8796 | 9509 | ||
8797 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 9510 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
8798 | { | 9511 | { |
8799 | int beginning = 0; | 9512 | return ParseString2List(src, separators, spacers, true); |
8800 | int srclen = src.Length; | 9513 | } |
8801 | int seplen = separators.Length; | ||
8802 | object[] separray = separators.Data; | ||
8803 | int spclen = spacers.Length; | ||
8804 | object[] spcarray = spacers.Data; | ||
8805 | int mlen = seplen+spclen; | ||
8806 | |||
8807 | int[] offset = new int[mlen+1]; | ||
8808 | bool[] active = new bool[mlen]; | ||
8809 | |||
8810 | int best; | ||
8811 | int j; | ||
8812 | |||
8813 | // Initial capacity reduces resize cost | ||
8814 | 9514 | ||
8815 | LSL_List tokens = new LSL_List(); | 9515 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
9516 | { | ||
9517 | int srclen = src.Length; | ||
9518 | int seplen = separators.Length; | ||
9519 | object[] separray = separators.Data; | ||
9520 | int spclen = spacers.Length; | ||
9521 | object[] spcarray = spacers.Data; | ||
9522 | int dellen = 0; | ||
9523 | string[] delarray = new string[seplen+spclen]; | ||
8816 | 9524 | ||
8817 | // All entries are initially valid | 9525 | int outlen = 0; |
9526 | string[] outarray = new string[srclen*2+1]; | ||
8818 | 9527 | ||
8819 | for (int i = 0; i < mlen; i++) | 9528 | int i, j; |
8820 | active[i] = true; | 9529 | string d; |
8821 | 9530 | ||
8822 | offset[mlen] = srclen; | 9531 | m_host.AddScriptLPS(1); |
8823 | 9532 | ||
8824 | while (beginning < srclen) | 9533 | /* |
9534 | * Convert separator and spacer lists to C# strings. | ||
9535 | * Also filter out null strings so we don't hang. | ||
9536 | */ | ||
9537 | for (i = 0; i < seplen; i ++) | ||
8825 | { | 9538 | { |
9539 | d = separray[i].ToString(); | ||
9540 | if (d.Length > 0) | ||
9541 | { | ||
9542 | delarray[dellen++] = d; | ||
9543 | } | ||
9544 | } | ||
9545 | seplen = dellen; | ||
8826 | 9546 | ||
8827 | best = mlen; // as bad as it gets | 9547 | for (i = 0; i < spclen; i ++) |
9548 | { | ||
9549 | d = spcarray[i].ToString(); | ||
9550 | if (d.Length > 0) | ||
9551 | { | ||
9552 | delarray[dellen++] = d; | ||
9553 | } | ||
9554 | } | ||
8828 | 9555 | ||
8829 | // Scan for separators | 9556 | /* |
9557 | * Scan through source string from beginning to end. | ||
9558 | */ | ||
9559 | for (i = 0;;) | ||
9560 | { | ||
8830 | 9561 | ||
8831 | for (j = 0; j < seplen; j++) | 9562 | /* |
9563 | * Find earliest delimeter in src starting at i (if any). | ||
9564 | */ | ||
9565 | int earliestDel = -1; | ||
9566 | int earliestSrc = srclen; | ||
9567 | string earliestStr = null; | ||
9568 | for (j = 0; j < dellen; j ++) | ||
8832 | { | 9569 | { |
8833 | if (separray[j].ToString() == String.Empty) | 9570 | d = delarray[j]; |
8834 | active[j] = false; | 9571 | if (d != null) |
8835 | |||
8836 | if (active[j]) | ||
8837 | { | 9572 | { |
8838 | // scan all of the markers | 9573 | int index = src.IndexOf(d, i); |
8839 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 9574 | if (index < 0) |
8840 | { | 9575 | { |
8841 | // not present at all | 9576 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
8842 | active[j] = false; | ||
8843 | } | 9577 | } |
8844 | else | 9578 | else if (index < earliestSrc) |
8845 | { | 9579 | { |
8846 | // present and correct | 9580 | earliestSrc = index; // where delimeter starts in source string |
8847 | if (offset[j] < offset[best]) | 9581 | earliestDel = j; // where delimeter is in delarray[] |
8848 | { | 9582 | earliestStr = d; // the delimeter string from delarray[] |
8849 | // closest so far | 9583 | if (index == i) break; // can't do any better than found at beg of string |
8850 | best = j; | ||
8851 | if (offset[best] == beginning) | ||
8852 | break; | ||
8853 | } | ||
8854 | } | 9584 | } |
8855 | } | 9585 | } |
8856 | } | 9586 | } |
8857 | 9587 | ||
8858 | // Scan for spacers | 9588 | /* |
8859 | 9589 | * Output source string starting at i through start of earliest delimeter. | |
8860 | if (offset[best] != beginning) | 9590 | */ |
9591 | if (keepNulls || (earliestSrc > i)) | ||
8861 | { | 9592 | { |
8862 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 9593 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
8863 | { | ||
8864 | if (spcarray[j-seplen].ToString() == String.Empty) | ||
8865 | active[j] = false; | ||
8866 | |||
8867 | if (active[j]) | ||
8868 | { | ||
8869 | // scan all of the markers | ||
8870 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | ||
8871 | { | ||
8872 | // not present at all | ||
8873 | active[j] = false; | ||
8874 | } | ||
8875 | else | ||
8876 | { | ||
8877 | // present and correct | ||
8878 | if (offset[j] < offset[best]) | ||
8879 | { | ||
8880 | // closest so far | ||
8881 | best = j; | ||
8882 | } | ||
8883 | } | ||
8884 | } | ||
8885 | } | ||
8886 | } | 9594 | } |
8887 | 9595 | ||
8888 | // This is the normal exit from the scanning loop | 9596 | /* |
9597 | * If no delimeter found at or after i, we're done scanning. | ||
9598 | */ | ||
9599 | if (earliestDel < 0) break; | ||
8889 | 9600 | ||
8890 | if (best == mlen) | 9601 | /* |
9602 | * If delimeter was a spacer, output the spacer. | ||
9603 | */ | ||
9604 | if (earliestDel >= seplen) | ||
8891 | { | 9605 | { |
8892 | // no markers were found on this pass | 9606 | outarray[outlen++] = earliestStr; |
8893 | // so we're pretty much done | ||
8894 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
8895 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8896 | break; | ||
8897 | } | 9607 | } |
8898 | 9608 | ||
8899 | // Otherwise we just add the newly delimited token | 9609 | /* |
8900 | // and recalculate where the search should continue. | 9610 | * Look at rest of src string following delimeter. |
8901 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 9611 | */ |
8902 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 9612 | i = earliestSrc + earliestStr.Length; |
8903 | |||
8904 | if (best < seplen) | ||
8905 | { | ||
8906 | beginning = offset[best] + (separray[best].ToString()).Length; | ||
8907 | } | ||
8908 | else | ||
8909 | { | ||
8910 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
8911 | string str = spcarray[best - seplen].ToString(); | ||
8912 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8913 | tokens.Add(new LSL_String(str)); | ||
8914 | } | ||
8915 | } | 9613 | } |
8916 | 9614 | ||
8917 | // This an awkward an not very intuitive boundary case. If the | 9615 | /* |
8918 | // last substring is a tokenizer, then there is an implied trailing | 9616 | * Make up an exact-sized output array suitable for an LSL_List object. |
8919 | // null list entry. Hopefully the single comparison will not be too | 9617 | */ |
8920 | // arduous. Alternatively the 'break' could be replced with a return | 9618 | object[] outlist = new object[outlen]; |
8921 | // but that's shabby programming. | 9619 | for (i = 0; i < outlen; i ++) |
8922 | |||
8923 | if ((beginning == srclen) && (keepNulls)) | ||
8924 | { | 9620 | { |
8925 | if (srclen != 0) | 9621 | outlist[i] = new LSL_String(outarray[i]); |
8926 | tokens.Add(new LSL_String("")); | ||
8927 | } | 9622 | } |
8928 | 9623 | return new LSL_List(outlist); | |
8929 | return tokens; | ||
8930 | } | ||
8931 | |||
8932 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
8933 | { | ||
8934 | m_host.AddScriptLPS(1); | ||
8935 | return this.ParseString(src, separators, spacers, false); | ||
8936 | } | ||
8937 | |||
8938 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8939 | { | ||
8940 | m_host.AddScriptLPS(1); | ||
8941 | return this.ParseString(src, separators, spacers, true); | ||
8942 | } | 9624 | } |
8943 | 9625 | ||
8944 | public LSL_Integer llGetObjectPermMask(int mask) | 9626 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -9015,28 +9697,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9015 | { | 9697 | { |
9016 | m_host.AddScriptLPS(1); | 9698 | m_host.AddScriptLPS(1); |
9017 | 9699 | ||
9018 | lock (m_host.TaskInventory) | 9700 | m_host.TaskInventory.LockItemsForRead(true); |
9701 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9019 | { | 9702 | { |
9020 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9703 | if (inv.Value.Name == item) |
9021 | { | 9704 | { |
9022 | if (inv.Value.Name == item) | 9705 | m_host.TaskInventory.LockItemsForRead(false); |
9706 | switch (mask) | ||
9023 | { | 9707 | { |
9024 | switch (mask) | 9708 | case 0: |
9025 | { | 9709 | return (int)inv.Value.BasePermissions; |
9026 | case 0: | 9710 | case 1: |
9027 | return (int)inv.Value.BasePermissions; | 9711 | return (int)inv.Value.CurrentPermissions; |
9028 | case 1: | 9712 | case 2: |
9029 | return (int)inv.Value.CurrentPermissions; | 9713 | return (int)inv.Value.GroupPermissions; |
9030 | case 2: | 9714 | case 3: |
9031 | return (int)inv.Value.GroupPermissions; | 9715 | return (int)inv.Value.EveryonePermissions; |
9032 | case 3: | 9716 | case 4: |
9033 | return (int)inv.Value.EveryonePermissions; | 9717 | return (int)inv.Value.NextPermissions; |
9034 | case 4: | ||
9035 | return (int)inv.Value.NextPermissions; | ||
9036 | } | ||
9037 | } | 9718 | } |
9038 | } | 9719 | } |
9039 | } | 9720 | } |
9721 | m_host.TaskInventory.LockItemsForRead(false); | ||
9040 | 9722 | ||
9041 | return -1; | 9723 | return -1; |
9042 | } | 9724 | } |
@@ -9083,16 +9765,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9083 | { | 9765 | { |
9084 | m_host.AddScriptLPS(1); | 9766 | m_host.AddScriptLPS(1); |
9085 | 9767 | ||
9086 | lock (m_host.TaskInventory) | 9768 | m_host.TaskInventory.LockItemsForRead(true); |
9769 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9087 | { | 9770 | { |
9088 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9771 | if (inv.Value.Name == item) |
9089 | { | 9772 | { |
9090 | if (inv.Value.Name == item) | 9773 | m_host.TaskInventory.LockItemsForRead(false); |
9091 | { | 9774 | return inv.Value.CreatorID.ToString(); |
9092 | return inv.Value.CreatorID.ToString(); | ||
9093 | } | ||
9094 | } | 9775 | } |
9095 | } | 9776 | } |
9777 | m_host.TaskInventory.LockItemsForRead(false); | ||
9096 | 9778 | ||
9097 | llSay(0, "No item name '" + item + "'"); | 9779 | llSay(0, "No item name '" + item + "'"); |
9098 | 9780 | ||
@@ -9218,9 +9900,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9218 | { | 9900 | { |
9219 | try | 9901 | try |
9220 | { | 9902 | { |
9903 | /* | ||
9221 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); | 9904 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); |
9222 | if (obj != null) | 9905 | if (obj != null) |
9223 | return (double)obj.GetMass(); | 9906 | return (double)obj.GetMass(); |
9907 | */ | ||
9908 | // return total object mass | ||
9909 | SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId); | ||
9910 | if (obj != null) | ||
9911 | return obj.GetMass(); | ||
9912 | |||
9224 | // the object is null so the key is for an avatar | 9913 | // the object is null so the key is for an avatar |
9225 | ScenePresence avatar = World.GetScenePresence(key); | 9914 | ScenePresence avatar = World.GetScenePresence(key); |
9226 | if (avatar != null) | 9915 | if (avatar != null) |
@@ -9240,7 +9929,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9240 | } | 9929 | } |
9241 | 9930 | ||
9242 | /// <summary> | 9931 | /// <summary> |
9243 | /// illListReplaceList removes the sub-list defined by the inclusive indices | 9932 | /// llListReplaceList removes the sub-list defined by the inclusive indices |
9244 | /// start and end and inserts the src list in its place. The inclusive | 9933 | /// start and end and inserts the src list in its place. The inclusive |
9245 | /// nature of the indices means that at least one element must be deleted | 9934 | /// nature of the indices means that at least one element must be deleted |
9246 | /// if the indices are within the bounds of the existing list. I.e. 2,2 | 9935 | /// if the indices are within the bounds of the existing list. I.e. 2,2 |
@@ -9297,16 +9986,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9297 | // based upon end. Note that if end exceeds the upper | 9986 | // based upon end. Note that if end exceeds the upper |
9298 | // bound in this case, the entire destination list | 9987 | // bound in this case, the entire destination list |
9299 | // is removed. | 9988 | // is removed. |
9300 | else | 9989 | else if (start == 0) |
9301 | { | 9990 | { |
9302 | if (end + 1 < dest.Length) | 9991 | if (end + 1 < dest.Length) |
9303 | { | ||
9304 | return src + dest.GetSublist(end + 1, -1); | 9992 | return src + dest.GetSublist(end + 1, -1); |
9305 | } | ||
9306 | else | 9993 | else |
9307 | { | ||
9308 | return src; | 9994 | return src; |
9309 | } | 9995 | } |
9996 | else // Start < 0 | ||
9997 | { | ||
9998 | if (end + 1 < dest.Length) | ||
9999 | return dest.GetSublist(end + 1, -1); | ||
10000 | else | ||
10001 | return new LSL_List(); | ||
9310 | } | 10002 | } |
9311 | } | 10003 | } |
9312 | // Finally, if start > end, we strip away a prefix and | 10004 | // Finally, if start > end, we strip away a prefix and |
@@ -9357,17 +10049,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9357 | int width = 0; | 10049 | int width = 0; |
9358 | int height = 0; | 10050 | int height = 0; |
9359 | 10051 | ||
9360 | ParcelMediaCommandEnum? commandToSend = null; | 10052 | uint commandToSend = 0; |
9361 | float time = 0.0f; // default is from start | 10053 | float time = 0.0f; // default is from start |
9362 | 10054 | ||
9363 | ScenePresence presence = null; | 10055 | ScenePresence presence = null; |
9364 | 10056 | ||
9365 | for (int i = 0; i < commandList.Data.Length; i++) | 10057 | for (int i = 0; i < commandList.Data.Length; i++) |
9366 | { | 10058 | { |
9367 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 10059 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
9368 | switch (command) | 10060 | switch (command) |
9369 | { | 10061 | { |
9370 | case ParcelMediaCommandEnum.Agent: | 10062 | case (uint)ParcelMediaCommandEnum.Agent: |
9371 | // we send only to one agent | 10063 | // we send only to one agent |
9372 | if ((i + 1) < commandList.Length) | 10064 | if ((i + 1) < commandList.Length) |
9373 | { | 10065 | { |
@@ -9384,25 +10076,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9384 | } | 10076 | } |
9385 | break; | 10077 | break; |
9386 | 10078 | ||
9387 | case ParcelMediaCommandEnum.Loop: | 10079 | case (uint)ParcelMediaCommandEnum.Loop: |
9388 | loop = 1; | 10080 | loop = 1; |
9389 | commandToSend = command; | 10081 | commandToSend = command; |
9390 | update = true; //need to send the media update packet to set looping | 10082 | update = true; //need to send the media update packet to set looping |
9391 | break; | 10083 | break; |
9392 | 10084 | ||
9393 | case ParcelMediaCommandEnum.Play: | 10085 | case (uint)ParcelMediaCommandEnum.Play: |
9394 | loop = 0; | 10086 | loop = 0; |
9395 | commandToSend = command; | 10087 | commandToSend = command; |
9396 | update = true; //need to send the media update packet to make sure it doesn't loop | 10088 | update = true; //need to send the media update packet to make sure it doesn't loop |
9397 | break; | 10089 | break; |
9398 | 10090 | ||
9399 | case ParcelMediaCommandEnum.Pause: | 10091 | case (uint)ParcelMediaCommandEnum.Pause: |
9400 | case ParcelMediaCommandEnum.Stop: | 10092 | case (uint)ParcelMediaCommandEnum.Stop: |
9401 | case ParcelMediaCommandEnum.Unload: | 10093 | case (uint)ParcelMediaCommandEnum.Unload: |
9402 | commandToSend = command; | 10094 | commandToSend = command; |
9403 | break; | 10095 | break; |
9404 | 10096 | ||
9405 | case ParcelMediaCommandEnum.Url: | 10097 | case (uint)ParcelMediaCommandEnum.Url: |
9406 | if ((i + 1) < commandList.Length) | 10098 | if ((i + 1) < commandList.Length) |
9407 | { | 10099 | { |
9408 | if (commandList.Data[i + 1] is LSL_String) | 10100 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9415,7 +10107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9415 | } | 10107 | } |
9416 | break; | 10108 | break; |
9417 | 10109 | ||
9418 | case ParcelMediaCommandEnum.Texture: | 10110 | case (uint)ParcelMediaCommandEnum.Texture: |
9419 | if ((i + 1) < commandList.Length) | 10111 | if ((i + 1) < commandList.Length) |
9420 | { | 10112 | { |
9421 | if (commandList.Data[i + 1] is LSL_String) | 10113 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9428,7 +10120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9428 | } | 10120 | } |
9429 | break; | 10121 | break; |
9430 | 10122 | ||
9431 | case ParcelMediaCommandEnum.Time: | 10123 | case (uint)ParcelMediaCommandEnum.Time: |
9432 | if ((i + 1) < commandList.Length) | 10124 | if ((i + 1) < commandList.Length) |
9433 | { | 10125 | { |
9434 | if (commandList.Data[i + 1] is LSL_Float) | 10126 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -9440,7 +10132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9440 | } | 10132 | } |
9441 | break; | 10133 | break; |
9442 | 10134 | ||
9443 | case ParcelMediaCommandEnum.AutoAlign: | 10135 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
9444 | if ((i + 1) < commandList.Length) | 10136 | if ((i + 1) < commandList.Length) |
9445 | { | 10137 | { |
9446 | if (commandList.Data[i + 1] is LSL_Integer) | 10138 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9454,7 +10146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9454 | } | 10146 | } |
9455 | break; | 10147 | break; |
9456 | 10148 | ||
9457 | case ParcelMediaCommandEnum.Type: | 10149 | case (uint)ParcelMediaCommandEnum.Type: |
9458 | if ((i + 1) < commandList.Length) | 10150 | if ((i + 1) < commandList.Length) |
9459 | { | 10151 | { |
9460 | if (commandList.Data[i + 1] is LSL_String) | 10152 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9467,7 +10159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9467 | } | 10159 | } |
9468 | break; | 10160 | break; |
9469 | 10161 | ||
9470 | case ParcelMediaCommandEnum.Desc: | 10162 | case (uint)ParcelMediaCommandEnum.Desc: |
9471 | if ((i + 1) < commandList.Length) | 10163 | if ((i + 1) < commandList.Length) |
9472 | { | 10164 | { |
9473 | if (commandList.Data[i + 1] is LSL_String) | 10165 | if (commandList.Data[i + 1] is LSL_String) |
@@ -9480,7 +10172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9480 | } | 10172 | } |
9481 | break; | 10173 | break; |
9482 | 10174 | ||
9483 | case ParcelMediaCommandEnum.Size: | 10175 | case (uint)ParcelMediaCommandEnum.Size: |
9484 | if ((i + 2) < commandList.Length) | 10176 | if ((i + 2) < commandList.Length) |
9485 | { | 10177 | { |
9486 | if (commandList.Data[i + 1] is LSL_Integer) | 10178 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -9550,7 +10242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9550 | } | 10242 | } |
9551 | } | 10243 | } |
9552 | 10244 | ||
9553 | if (commandToSend != null) | 10245 | if (commandToSend != 0) |
9554 | { | 10246 | { |
9555 | // the commandList contained a start/stop/... command, too | 10247 | // the commandList contained a start/stop/... command, too |
9556 | if (presence == null) | 10248 | if (presence == null) |
@@ -9587,7 +10279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9587 | 10279 | ||
9588 | if (aList.Data[i] != null) | 10280 | if (aList.Data[i] != null) |
9589 | { | 10281 | { |
9590 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 10282 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
9591 | { | 10283 | { |
9592 | case ParcelMediaCommandEnum.Url: | 10284 | case ParcelMediaCommandEnum.Url: |
9593 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 10285 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); |
@@ -9630,16 +10322,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9630 | { | 10322 | { |
9631 | m_host.AddScriptLPS(1); | 10323 | m_host.AddScriptLPS(1); |
9632 | 10324 | ||
9633 | lock (m_host.TaskInventory) | 10325 | m_host.TaskInventory.LockItemsForRead(true); |
10326 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
9634 | { | 10327 | { |
9635 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 10328 | if (inv.Value.Name == name) |
9636 | { | 10329 | { |
9637 | if (inv.Value.Name == name) | 10330 | m_host.TaskInventory.LockItemsForRead(false); |
9638 | { | 10331 | return inv.Value.Type; |
9639 | return inv.Value.Type; | ||
9640 | } | ||
9641 | } | 10332 | } |
9642 | } | 10333 | } |
10334 | m_host.TaskInventory.LockItemsForRead(false); | ||
9643 | 10335 | ||
9644 | return -1; | 10336 | return -1; |
9645 | } | 10337 | } |
@@ -9650,15 +10342,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9650 | 10342 | ||
9651 | if (quick_pay_buttons.Data.Length < 4) | 10343 | if (quick_pay_buttons.Data.Length < 4) |
9652 | { | 10344 | { |
9653 | LSLError("List must have at least 4 elements"); | 10345 | int x; |
9654 | return; | 10346 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
10347 | { | ||
10348 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
10349 | } | ||
9655 | } | 10350 | } |
9656 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 10351 | int[] nPrice = new int[5]; |
9657 | 10352 | nPrice[0] = price; | |
9658 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 10353 | nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0); |
9659 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 10354 | nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1); |
9660 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 10355 | nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2); |
9661 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 10356 | nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3); |
10357 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
9662 | m_host.ParentGroup.HasGroupChanged = true; | 10358 | m_host.ParentGroup.HasGroupChanged = true; |
9663 | } | 10359 | } |
9664 | 10360 | ||
@@ -9674,8 +10370,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9674 | ShoutError("No permissions to track the camera"); | 10370 | ShoutError("No permissions to track the camera"); |
9675 | return new LSL_Vector(); | 10371 | return new LSL_Vector(); |
9676 | } | 10372 | } |
10373 | m_host.TaskInventory.LockItemsForRead(false); | ||
9677 | 10374 | ||
9678 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 10375 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
10376 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
9679 | if (presence != null) | 10377 | if (presence != null) |
9680 | { | 10378 | { |
9681 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); | 10379 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); |
@@ -9696,8 +10394,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9696 | ShoutError("No permissions to track the camera"); | 10394 | ShoutError("No permissions to track the camera"); |
9697 | return new LSL_Rotation(); | 10395 | return new LSL_Rotation(); |
9698 | } | 10396 | } |
10397 | m_host.TaskInventory.LockItemsForRead(false); | ||
9699 | 10398 | ||
9700 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 10399 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
10400 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
9701 | if (presence != null) | 10401 | if (presence != null) |
9702 | { | 10402 | { |
9703 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); | 10403 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); |
@@ -9757,8 +10457,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9757 | { | 10457 | { |
9758 | m_host.AddScriptLPS(1); | 10458 | m_host.AddScriptLPS(1); |
9759 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); | 10459 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); |
9760 | if (detectedParams == null) return; // only works on the first detected avatar | 10460 | if (detectedParams == null) |
9761 | 10461 | { | |
10462 | if (m_host.ParentGroup.IsAttachment == true) | ||
10463 | { | ||
10464 | detectedParams = new DetectParams(); | ||
10465 | detectedParams.Key = m_host.OwnerID; | ||
10466 | } | ||
10467 | else | ||
10468 | { | ||
10469 | return; | ||
10470 | } | ||
10471 | } | ||
10472 | |||
9762 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 10473 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9763 | if (avatar != null) | 10474 | if (avatar != null) |
9764 | { | 10475 | { |
@@ -9766,6 +10477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9766 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 10477 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9767 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 10478 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9768 | } | 10479 | } |
10480 | |||
9769 | ScriptSleep(1000); | 10481 | ScriptSleep(1000); |
9770 | } | 10482 | } |
9771 | 10483 | ||
@@ -9889,12 +10601,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9889 | 10601 | ||
9890 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); | 10602 | SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); |
9891 | object[] data = rules.Data; | 10603 | object[] data = rules.Data; |
9892 | for (int i = 0; i < data.Length; ++i) { | 10604 | for (int i = 0; i < data.Length; ++i) |
10605 | { | ||
9893 | int type = Convert.ToInt32(data[i++].ToString()); | 10606 | int type = Convert.ToInt32(data[i++].ToString()); |
9894 | if (i >= data.Length) break; // odd number of entries => ignore the last | 10607 | if (i >= data.Length) break; // odd number of entries => ignore the last |
9895 | 10608 | ||
9896 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | 10609 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) |
9897 | switch (type) { | 10610 | switch (type) |
10611 | { | ||
9898 | case ScriptBaseClass.CAMERA_FOCUS: | 10612 | case ScriptBaseClass.CAMERA_FOCUS: |
9899 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: | 10613 | case ScriptBaseClass.CAMERA_FOCUS_OFFSET: |
9900 | case ScriptBaseClass.CAMERA_POSITION: | 10614 | case ScriptBaseClass.CAMERA_POSITION: |
@@ -10000,19 +10714,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10000 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 10714 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
10001 | { | 10715 | { |
10002 | m_host.AddScriptLPS(1); | 10716 | m_host.AddScriptLPS(1); |
10003 | string ret = String.Empty; | 10717 | |
10004 | string src1 = llBase64ToString(str1); | 10718 | if (str1 == String.Empty) |
10005 | string src2 = llBase64ToString(str2); | 10719 | return String.Empty; |
10006 | int c = 0; | 10720 | if (str2 == String.Empty) |
10007 | for (int i = 0; i < src1.Length; i++) | 10721 | return str1; |
10722 | |||
10723 | int len = str2.Length; | ||
10724 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
10725 | { | ||
10726 | while (str2.EndsWith("=")) | ||
10727 | str2 = str2.Substring(0, str2.Length - 1); | ||
10728 | |||
10729 | len = str2.Length; | ||
10730 | int mod = len % 4; | ||
10731 | |||
10732 | if (mod == 1) | ||
10733 | str2 = str2.Substring(0, str2.Length - 1); | ||
10734 | else if (mod == 2) | ||
10735 | str2 += "=="; | ||
10736 | else if (mod == 3) | ||
10737 | str2 += "="; | ||
10738 | } | ||
10739 | |||
10740 | byte[] data1; | ||
10741 | byte[] data2; | ||
10742 | try | ||
10743 | { | ||
10744 | data1 = Convert.FromBase64String(str1); | ||
10745 | data2 = Convert.FromBase64String(str2); | ||
10746 | } | ||
10747 | catch (Exception) | ||
10748 | { | ||
10749 | return new LSL_String(String.Empty); | ||
10750 | } | ||
10751 | |||
10752 | byte[] d2 = new Byte[data1.Length]; | ||
10753 | int pos = 0; | ||
10754 | |||
10755 | if (data1.Length <= data2.Length) | ||
10008 | { | 10756 | { |
10009 | ret += (char) (src1[i] ^ src2[c]); | 10757 | Array.Copy(data2, 0, d2, 0, data1.Length); |
10758 | } | ||
10759 | else | ||
10760 | { | ||
10761 | while (pos < data1.Length) | ||
10762 | { | ||
10763 | len = data1.Length - pos; | ||
10764 | if (len > data2.Length) | ||
10765 | len = data2.Length; | ||
10010 | 10766 | ||
10011 | c++; | 10767 | Array.Copy(data2, 0, d2, pos, len); |
10012 | if (c >= src2.Length) | 10768 | pos += len; |
10013 | c = 0; | 10769 | } |
10014 | } | 10770 | } |
10015 | return llStringToBase64(ret); | 10771 | |
10772 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
10773 | data1[pos] ^= d2[pos]; | ||
10774 | |||
10775 | return Convert.ToBase64String(data1); | ||
10016 | } | 10776 | } |
10017 | 10777 | ||
10018 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 10778 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -10069,12 +10829,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10069 | Regex r = new Regex(authregex); | 10829 | Regex r = new Regex(authregex); |
10070 | int[] gnums = r.GetGroupNumbers(); | 10830 | int[] gnums = r.GetGroupNumbers(); |
10071 | Match m = r.Match(url); | 10831 | Match m = r.Match(url); |
10072 | if (m.Success) { | 10832 | if (m.Success) |
10073 | for (int i = 1; i < gnums.Length; i++) { | 10833 | { |
10834 | for (int i = 1; i < gnums.Length; i++) | ||
10835 | { | ||
10074 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; | 10836 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; |
10075 | //CaptureCollection cc = g.Captures; | 10837 | //CaptureCollection cc = g.Captures; |
10076 | } | 10838 | } |
10077 | if (m.Groups.Count == 5) { | 10839 | if (m.Groups.Count == 5) |
10840 | { | ||
10078 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); | 10841 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); |
10079 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); | 10842 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); |
10080 | } | 10843 | } |
@@ -10437,15 +11200,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10437 | 11200 | ||
10438 | internal UUID ScriptByName(string name) | 11201 | internal UUID ScriptByName(string name) |
10439 | { | 11202 | { |
10440 | lock (m_host.TaskInventory) | 11203 | m_host.TaskInventory.LockItemsForRead(true); |
11204 | |||
11205 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
10441 | { | 11206 | { |
10442 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 11207 | if (item.Type == 10 && item.Name == name) |
10443 | { | 11208 | { |
10444 | if (item.Type == 10 && item.Name == name) | 11209 | m_host.TaskInventory.LockItemsForRead(false); |
10445 | return item.ItemID; | 11210 | return item.ItemID; |
10446 | } | 11211 | } |
10447 | } | 11212 | } |
10448 | 11213 | ||
11214 | m_host.TaskInventory.LockItemsForRead(false); | ||
11215 | |||
10449 | return UUID.Zero; | 11216 | return UUID.Zero; |
10450 | } | 11217 | } |
10451 | 11218 | ||
@@ -10486,6 +11253,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10486 | { | 11253 | { |
10487 | m_host.AddScriptLPS(1); | 11254 | m_host.AddScriptLPS(1); |
10488 | 11255 | ||
11256 | //Clone is thread safe | ||
10489 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 11257 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10490 | 11258 | ||
10491 | UUID assetID = UUID.Zero; | 11259 | UUID assetID = UUID.Zero; |
@@ -10548,6 +11316,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10548 | { | 11316 | { |
10549 | m_host.AddScriptLPS(1); | 11317 | m_host.AddScriptLPS(1); |
10550 | 11318 | ||
11319 | //Clone is thread safe | ||
10551 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 11320 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
10552 | 11321 | ||
10553 | UUID assetID = UUID.Zero; | 11322 | UUID assetID = UUID.Zero; |
@@ -10628,15 +11397,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10628 | return GetLinkPrimitiveParams(obj, rules); | 11397 | return GetLinkPrimitiveParams(obj, rules); |
10629 | } | 11398 | } |
10630 | 11399 | ||
10631 | public void print(string str) | 11400 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
10632 | { | 11401 | { |
10633 | // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print | 11402 | List<SceneObjectPart> parts = GetLinkParts(link); |
10634 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); | 11403 | if (parts.Count < 1) |
10635 | if (ossl != null) | 11404 | return 0; |
10636 | { | 11405 | |
10637 | ossl.CheckThreatLevel(ThreatLevel.High, "print"); | 11406 | return GetNumberOfSides(parts[0]); |
10638 | m_log.Info("LSL print():" + str); | ||
10639 | } | ||
10640 | } | 11407 | } |
10641 | 11408 | ||
10642 | private string Name2Username(string name) | 11409 | private string Name2Username(string name) |
@@ -10682,155 +11449,482 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10682 | return rq.ToString(); | 11449 | return rq.ToString(); |
10683 | } | 11450 | } |
10684 | 11451 | ||
11452 | private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) | ||
11453 | { | ||
11454 | m_SayShoutCount = 0; | ||
11455 | } | ||
11456 | |||
11457 | private struct Tri | ||
11458 | { | ||
11459 | public Vector3 p1; | ||
11460 | public Vector3 p2; | ||
11461 | public Vector3 p3; | ||
11462 | } | ||
11463 | |||
11464 | private bool InBoundingBox(ScenePresence avatar, Vector3 point) | ||
11465 | { | ||
11466 | float height = avatar.Appearance.AvatarHeight; | ||
11467 | Vector3 b1 = avatar.AbsolutePosition + new Vector3(-0.22f, -0.22f, -height/2); | ||
11468 | Vector3 b2 = avatar.AbsolutePosition + new Vector3(0.22f, 0.22f, height/2); | ||
11469 | |||
11470 | if (point.X > b1.X && point.X < b2.X && | ||
11471 | point.Y > b1.Y && point.Y < b2.Y && | ||
11472 | point.Z > b1.Z && point.Z < b2.Z) | ||
11473 | return true; | ||
11474 | return false; | ||
11475 | } | ||
11476 | |||
11477 | private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd) | ||
11478 | { | ||
11479 | List<ContactResult> contacts = new List<ContactResult>(); | ||
11480 | |||
11481 | Vector3 ab = rayEnd - rayStart; | ||
11482 | |||
11483 | World.ForEachScenePresence(delegate(ScenePresence sp) | ||
11484 | { | ||
11485 | Vector3 ac = sp.AbsolutePosition - rayStart; | ||
11486 | Vector3 bc = sp.AbsolutePosition - rayEnd; | ||
11487 | |||
11488 | double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); | ||
11489 | |||
11490 | if (d > 1.5) | ||
11491 | return; | ||
11492 | |||
11493 | double d2 = Vector3.Dot(Vector3.Negate(ab), ac); | ||
11494 | |||
11495 | if (d2 > 0) | ||
11496 | return; | ||
11497 | |||
11498 | double dp = Math.Sqrt(Vector3.Mag(ac) * Vector3.Mag(ac) - d * d); | ||
11499 | Vector3 p = rayStart + Vector3.Divide(Vector3.Multiply(ab, (float)dp), (float)Vector3.Mag(ab)); | ||
11500 | |||
11501 | if (!InBoundingBox(sp, p)) | ||
11502 | return; | ||
11503 | |||
11504 | ContactResult result = new ContactResult (); | ||
11505 | result.ConsumerID = sp.LocalId; | ||
11506 | result.Depth = Vector3.Distance(rayStart, p); | ||
11507 | result.Normal = Vector3.Zero; | ||
11508 | result.Pos = p; | ||
11509 | |||
11510 | contacts.Add(result); | ||
11511 | }); | ||
11512 | |||
11513 | return contacts.ToArray(); | ||
11514 | } | ||
11515 | |||
11516 | private ContactResult[] ObjectIntersection(Vector3 rayStart, Vector3 rayEnd, bool includePhysical, bool includeNonPhysical, bool includePhantom) | ||
11517 | { | ||
11518 | Ray ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart)); | ||
11519 | List<ContactResult> contacts = new List<ContactResult>(); | ||
11520 | |||
11521 | Vector3 ab = rayEnd - rayStart; | ||
11522 | |||
11523 | World.ForEachSOG(delegate(SceneObjectGroup group) | ||
11524 | { | ||
11525 | if (m_host.ParentGroup == group) | ||
11526 | return; | ||
11527 | |||
11528 | if (group.IsAttachment) | ||
11529 | return; | ||
11530 | |||
11531 | if (group.RootPart.PhysActor == null) | ||
11532 | { | ||
11533 | if (!includePhantom) | ||
11534 | return; | ||
11535 | } | ||
11536 | else | ||
11537 | { | ||
11538 | if (group.RootPart.PhysActor.IsPhysical) | ||
11539 | { | ||
11540 | if (!includePhysical) | ||
11541 | return; | ||
11542 | } | ||
11543 | else | ||
11544 | { | ||
11545 | if (!includeNonPhysical) | ||
11546 | return; | ||
11547 | } | ||
11548 | } | ||
11549 | |||
11550 | // Find the radius ouside of which we don't even need to hit test | ||
11551 | float minX; | ||
11552 | float maxX; | ||
11553 | float minY; | ||
11554 | float maxY; | ||
11555 | float minZ; | ||
11556 | float maxZ; | ||
11557 | |||
11558 | float radius = 0.0f; | ||
11559 | |||
11560 | group.GetAxisAlignedBoundingBoxRaw(out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
11561 | |||
11562 | if (Math.Abs(minX) > radius) | ||
11563 | radius = Math.Abs(minX); | ||
11564 | if (Math.Abs(minY) > radius) | ||
11565 | radius = Math.Abs(minY); | ||
11566 | if (Math.Abs(minZ) > radius) | ||
11567 | radius = Math.Abs(minZ); | ||
11568 | if (Math.Abs(maxX) > radius) | ||
11569 | radius = Math.Abs(maxX); | ||
11570 | if (Math.Abs(maxY) > radius) | ||
11571 | radius = Math.Abs(maxY); | ||
11572 | if (Math.Abs(maxZ) > radius) | ||
11573 | radius = Math.Abs(maxZ); | ||
11574 | |||
11575 | Vector3 ac = group.AbsolutePosition - rayStart; | ||
11576 | Vector3 bc = group.AbsolutePosition - rayEnd; | ||
11577 | |||
11578 | double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); | ||
11579 | |||
11580 | // Too far off ray, don't bother | ||
11581 | if (d > radius) | ||
11582 | return; | ||
11583 | |||
11584 | // Behind ray, drop | ||
11585 | double d2 = Vector3.Dot(Vector3.Negate(ab), ac); | ||
11586 | if (d2 > 0) | ||
11587 | return; | ||
11588 | |||
11589 | EntityIntersection intersection = group.TestIntersection(ray, true, false); | ||
11590 | // Miss. | ||
11591 | if (!intersection.HitTF) | ||
11592 | return; | ||
11593 | |||
11594 | ContactResult result = new ContactResult (); | ||
11595 | result.ConsumerID = group.LocalId; | ||
11596 | result.Depth = intersection.distance; | ||
11597 | result.Normal = intersection.normal; | ||
11598 | result.Pos = intersection.ipoint; | ||
11599 | |||
11600 | contacts.Add(result); | ||
11601 | }); | ||
11602 | |||
11603 | return contacts.ToArray(); | ||
11604 | } | ||
11605 | |||
11606 | private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd) | ||
11607 | { | ||
11608 | double[,] heightfield = World.Heightmap.GetDoubles(); | ||
11609 | List<ContactResult> contacts = new List<ContactResult>(); | ||
11610 | |||
11611 | double min = 2048.0; | ||
11612 | double max = 0.0; | ||
11613 | |||
11614 | // Find the min and max of the heightfield | ||
11615 | for (int x = 0 ; x < World.Heightmap.Width ; x++) | ||
11616 | { | ||
11617 | for (int y = 0 ; y < World.Heightmap.Height ; y++) | ||
11618 | { | ||
11619 | if (heightfield[x, y] > max) | ||
11620 | max = heightfield[x, y]; | ||
11621 | if (heightfield[x, y] < min) | ||
11622 | min = heightfield[x, y]; | ||
11623 | } | ||
11624 | } | ||
11625 | |||
11626 | |||
11627 | // A ray extends past rayEnd, but doesn't go back before | ||
11628 | // rayStart. If the start is above the highest point of the ground | ||
11629 | // and the ray goes up, we can't hit the ground. Ever. | ||
11630 | if (rayStart.Z > max && rayEnd.Z >= rayStart.Z) | ||
11631 | return null; | ||
11632 | |||
11633 | // Same for going down | ||
11634 | if (rayStart.Z < min && rayEnd.Z <= rayStart.Z) | ||
11635 | return null; | ||
11636 | |||
11637 | List<Tri> trilist = new List<Tri>(); | ||
11638 | |||
11639 | // Create our triangle list | ||
11640 | for (int x = 1 ; x < World.Heightmap.Width ; x++) | ||
11641 | { | ||
11642 | for (int y = 1 ; y < World.Heightmap.Height ; y++) | ||
11643 | { | ||
11644 | Tri t1 = new Tri(); | ||
11645 | Tri t2 = new Tri(); | ||
11646 | |||
11647 | Vector3 p1 = new Vector3(x-1, y-1, (float)heightfield[x-1, y-1]); | ||
11648 | Vector3 p2 = new Vector3(x, y-1, (float)heightfield[x, y-1]); | ||
11649 | Vector3 p3 = new Vector3(x, y, (float)heightfield[x, y]); | ||
11650 | Vector3 p4 = new Vector3(x-1, y, (float)heightfield[x-1, y]); | ||
11651 | |||
11652 | t1.p1 = p1; | ||
11653 | t1.p2 = p2; | ||
11654 | t1.p3 = p3; | ||
11655 | |||
11656 | t2.p1 = p3; | ||
11657 | t2.p2 = p4; | ||
11658 | t2.p3 = p1; | ||
11659 | |||
11660 | trilist.Add(t1); | ||
11661 | trilist.Add(t2); | ||
11662 | } | ||
11663 | } | ||
11664 | |||
11665 | // Ray direction | ||
11666 | Vector3 rayDirection = rayEnd - rayStart; | ||
11667 | |||
11668 | foreach (Tri t in trilist) | ||
11669 | { | ||
11670 | // Compute triangle plane normal and edges | ||
11671 | Vector3 u = t.p2 - t.p1; | ||
11672 | Vector3 v = t.p3 - t.p1; | ||
11673 | Vector3 n = Vector3.Cross(u, v); | ||
11674 | |||
11675 | if (n == Vector3.Zero) | ||
11676 | continue; | ||
11677 | |||
11678 | Vector3 w0 = rayStart - t.p1; | ||
11679 | double a = -Vector3.Dot(n, w0); | ||
11680 | double b = Vector3.Dot(n, rayDirection); | ||
11681 | |||
11682 | // Not intersecting the plane, or in plane (same thing) | ||
11683 | // Ignoring this MAY cause the ground to not be detected | ||
11684 | // sometimes | ||
11685 | if (Math.Abs(b) < 0.000001) | ||
11686 | continue; | ||
11687 | |||
11688 | double r = a / b; | ||
11689 | |||
11690 | // ray points away from plane | ||
11691 | if (r < 0.0) | ||
11692 | continue; | ||
11693 | |||
11694 | Vector3 ip = rayStart + Vector3.Multiply(rayDirection, (float)r); | ||
11695 | |||
11696 | float uu = Vector3.Dot(u, u); | ||
11697 | float uv = Vector3.Dot(u, v); | ||
11698 | float vv = Vector3.Dot(v, v); | ||
11699 | Vector3 w = ip - t.p1; | ||
11700 | float wu = Vector3.Dot(w, u); | ||
11701 | float wv = Vector3.Dot(w, v); | ||
11702 | float d = uv * uv - uu * vv; | ||
11703 | |||
11704 | float cs = (uv * wv - vv * wu) / d; | ||
11705 | if (cs < 0 || cs > 1.0) | ||
11706 | continue; | ||
11707 | float ct = (uv * wu - uu * wv) / d; | ||
11708 | if (ct < 0 || (cs + ct) > 1.0) | ||
11709 | continue; | ||
11710 | |||
11711 | // Add contact point | ||
11712 | ContactResult result = new ContactResult (); | ||
11713 | result.ConsumerID = 0; | ||
11714 | result.Depth = Vector3.Distance(rayStart, ip); | ||
11715 | result.Normal = n; | ||
11716 | result.Pos = ip; | ||
11717 | |||
11718 | contacts.Add(result); | ||
11719 | } | ||
11720 | |||
11721 | if (contacts.Count == 0) | ||
11722 | return null; | ||
11723 | |||
11724 | contacts.Sort(delegate(ContactResult a, ContactResult b) | ||
11725 | { | ||
11726 | return (int)(a.Depth - b.Depth); | ||
11727 | }); | ||
11728 | |||
11729 | return contacts[0]; | ||
11730 | } | ||
11731 | /* | ||
11732 | // not done: | ||
11733 | private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght) | ||
11734 | { | ||
11735 | ContactResult[] contacts = null; | ||
11736 | World.ForEachSOG(delegate(SceneObjectGroup group) | ||
11737 | { | ||
11738 | if (m_host.ParentGroup == group) | ||
11739 | return; | ||
11740 | |||
11741 | if (group.IsAttachment) | ||
11742 | return; | ||
11743 | |||
11744 | if(group.RootPart.PhysActor != null) | ||
11745 | return; | ||
11746 | |||
11747 | contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght); | ||
11748 | }); | ||
11749 | return contacts; | ||
11750 | } | ||
11751 | */ | ||
11752 | |||
10685 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | 11753 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) |
10686 | { | 11754 | { |
11755 | LSL_List list = new LSL_List(); | ||
11756 | |||
10687 | m_host.AddScriptLPS(1); | 11757 | m_host.AddScriptLPS(1); |
10688 | 11758 | ||
10689 | Vector3 dir = new Vector3((float)(end-start).x, (float)(end-start).y, (float)(end-start).z); | 11759 | Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z); |
10690 | Vector3 startvector = new Vector3((float)start.x, (float)start.y, (float)start.z); | 11760 | Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z); |
10691 | Vector3 endvector = new Vector3((float)end.x, (float)end.y, (float)end.z); | 11761 | Vector3 dir = rayEnd - rayStart; |
10692 | 11762 | ||
10693 | int count = 0; | 11763 | float dist = Vector3.Mag(dir); |
10694 | // int detectPhantom = 0; | 11764 | |
11765 | int count = 1; | ||
11766 | bool detectPhantom = false; | ||
10695 | int dataFlags = 0; | 11767 | int dataFlags = 0; |
10696 | int rejectTypes = 0; | 11768 | int rejectTypes = 0; |
10697 | 11769 | ||
10698 | for (int i = 0; i < options.Length; i += 2) | 11770 | for (int i = 0; i < options.Length; i += 2) |
10699 | { | 11771 | { |
10700 | if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS) | 11772 | if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS) |
10701 | { | ||
10702 | count = options.GetLSLIntegerItem(i + 1); | 11773 | count = options.GetLSLIntegerItem(i + 1); |
10703 | } | 11774 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM) |
10704 | // else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM) | 11775 | detectPhantom = (options.GetLSLIntegerItem(i + 1) > 0); |
10705 | // { | ||
10706 | // detectPhantom = options.GetLSLIntegerItem(i + 1); | ||
10707 | // } | ||
10708 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS) | 11776 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS) |
10709 | { | ||
10710 | dataFlags = options.GetLSLIntegerItem(i + 1); | 11777 | dataFlags = options.GetLSLIntegerItem(i + 1); |
10711 | } | ||
10712 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES) | 11778 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES) |
10713 | { | ||
10714 | rejectTypes = options.GetLSLIntegerItem(i + 1); | 11779 | rejectTypes = options.GetLSLIntegerItem(i + 1); |
10715 | } | ||
10716 | } | 11780 | } |
10717 | 11781 | ||
10718 | LSL_List list = new LSL_List(); | 11782 | if (count > 16) |
10719 | List<ContactResult> results = World.PhysicsScene.RaycastWorld(startvector, dir, dir.Length(), count); | 11783 | count = 16; |
10720 | |||
10721 | double distance = Util.GetDistanceTo(startvector, endvector); | ||
10722 | |||
10723 | if (distance == 0) | ||
10724 | distance = 0.001; | ||
10725 | 11784 | ||
10726 | Vector3 posToCheck = startvector; | 11785 | List<ContactResult> results = new List<ContactResult>(); |
10727 | ITerrainChannel channel = World.RequestModuleInterface<ITerrainChannel>(); | ||
10728 | 11786 | ||
10729 | bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND); | 11787 | bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND); |
10730 | bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS); | 11788 | bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS); |
10731 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); | 11789 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); |
10732 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | 11790 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); |
10733 | 11791 | ||
10734 | for (float i = 0; i <= distance; i += 0.1f) | 11792 | |
11793 | if (World.SuportsRayCastFiltered()) | ||
10735 | { | 11794 | { |
10736 | posToCheck = startvector + (dir * (i / (float)distance)); | 11795 | if (dist == 0) |
11796 | return list; | ||
11797 | |||
11798 | RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull; | ||
11799 | if (checkTerrain) | ||
11800 | rayfilter |= RayFilterFlags.land; | ||
11801 | // if (checkAgents) | ||
11802 | // rayfilter |= RayFilterFlags.agent; | ||
11803 | if (checkPhysical) | ||
11804 | rayfilter |= RayFilterFlags.physical; | ||
11805 | if (checkNonPhysical) | ||
11806 | rayfilter |= RayFilterFlags.nonphysical; | ||
11807 | if (detectPhantom) | ||
11808 | rayfilter |= RayFilterFlags.LSLPhanton; | ||
10737 | 11809 | ||
10738 | if (checkTerrain && channel[(int)(posToCheck.X + startvector.X), (int)(posToCheck.Y + startvector.Y)] < posToCheck.Z) | 11810 | Vector3 direction = dir * ( 1/dist); |
11811 | |||
11812 | if(rayfilter == 0) | ||
10739 | { | 11813 | { |
10740 | ContactResult result = new ContactResult(); | 11814 | list.Add(new LSL_Integer(0)); |
10741 | result.ConsumerID = 0; | 11815 | return list; |
10742 | result.Depth = 0; | ||
10743 | result.Normal = Vector3.Zero; | ||
10744 | result.Pos = posToCheck; | ||
10745 | results.Add(result); | ||
10746 | checkTerrain = false; | ||
10747 | } | 11816 | } |
10748 | 11817 | ||
10749 | if (checkAgents) | 11818 | // get some more contacts to sort ??? |
11819 | int physcount = 4 * count; | ||
11820 | if (physcount > 20) | ||
11821 | physcount = 20; | ||
11822 | |||
11823 | object physresults; | ||
11824 | physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter); | ||
11825 | |||
11826 | if (physresults == null) | ||
10750 | { | 11827 | { |
10751 | World.ForEachRootScenePresence(delegate(ScenePresence sp) | 11828 | list.Add(new LSL_Integer(-3)); // timeout error |
10752 | { | 11829 | return list; |
10753 | if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) | ||
10754 | { | ||
10755 | ContactResult result = new ContactResult (); | ||
10756 | result.ConsumerID = sp.LocalId; | ||
10757 | result.Depth = 0; | ||
10758 | result.Normal = Vector3.Zero; | ||
10759 | result.Pos = posToCheck; | ||
10760 | results.Add(result); | ||
10761 | } | ||
10762 | }); | ||
10763 | } | 11830 | } |
10764 | } | ||
10765 | 11831 | ||
10766 | int refcount = 0; | 11832 | results = (List<ContactResult>)physresults; |
10767 | foreach (ContactResult result in results) | ||
10768 | { | ||
10769 | if ((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) | ||
10770 | == ScriptBaseClass.RC_REJECT_LAND && result.ConsumerID == 0) | ||
10771 | continue; | ||
10772 | 11833 | ||
10773 | ISceneEntity entity = World.GetSceneObjectPart(result.ConsumerID); | 11834 | // for now physics doesn't detect sitted avatars so do it outside physics |
11835 | if (checkAgents) | ||
11836 | { | ||
11837 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | ||
11838 | foreach (ContactResult r in agentHits) | ||
11839 | results.Add(r); | ||
11840 | } | ||
10774 | 11841 | ||
10775 | if (entity == null && (rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) != ScriptBaseClass.RC_REJECT_AGENTS) | 11842 | // bug: will not detect phantom unless they are physical |
10776 | entity = World.GetScenePresence(result.ConsumerID); //Only check if we should be looking for agents | 11843 | // don't use ObjectIntersection because its also bad |
11844 | |||
11845 | } | ||
11846 | else | ||
11847 | { | ||
11848 | if (checkTerrain) | ||
11849 | { | ||
11850 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | ||
11851 | if (groundContact != null) | ||
11852 | results.Add((ContactResult)groundContact); | ||
11853 | } | ||
10777 | 11854 | ||
10778 | if (entity == null) | 11855 | if (checkAgents) |
10779 | { | 11856 | { |
10780 | list.Add(UUID.Zero); | 11857 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); |
11858 | foreach (ContactResult r in agentHits) | ||
11859 | results.Add(r); | ||
11860 | } | ||
10781 | 11861 | ||
10782 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) | 11862 | if (checkPhysical || checkNonPhysical || detectPhantom) |
10783 | list.Add(0); | 11863 | { |
11864 | ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); | ||
11865 | foreach (ContactResult r in objectHits) | ||
11866 | results.Add(r); | ||
11867 | } | ||
11868 | } | ||
10784 | 11869 | ||
10785 | list.Add(result.Pos); | 11870 | results.Sort(delegate(ContactResult a, ContactResult b) |
11871 | { | ||
11872 | return a.Depth.CompareTo(b.Depth); | ||
11873 | }); | ||
11874 | |||
11875 | int values = 0; | ||
11876 | SceneObjectGroup thisgrp = m_host.ParentGroup; | ||
10786 | 11877 | ||
10787 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) | 11878 | foreach (ContactResult result in results) |
10788 | list.Add(result.Normal); | 11879 | { |
11880 | if (result.Depth > dist) | ||
11881 | continue; | ||
10789 | 11882 | ||
10790 | continue; //Can't find it, so add UUID.Zero | 11883 | // physics ray can return colisions with host prim |
10791 | } | 11884 | if (m_host.LocalId == result.ConsumerID) |
11885 | continue; | ||
10792 | 11886 | ||
10793 | /*if (detectPhantom == 0 && intersection.obj is ISceneChildEntity && | 11887 | UUID itemID = UUID.Zero; |
10794 | ((ISceneChildEntity)intersection.obj).PhysActor == null) | 11888 | int linkNum = 0; |
10795 | continue;*/ //Can't do this ATM, physics engine knows only of non phantom objects | ||
10796 | 11889 | ||
10797 | if (entity is SceneObjectPart) | 11890 | SceneObjectPart part = World.GetSceneObjectPart(result.ConsumerID); |
11891 | // It's a prim! | ||
11892 | if (part != null) | ||
10798 | { | 11893 | { |
10799 | PhysicsActor pa = ((SceneObjectPart)entity).PhysActor; | 11894 | // dont detect members of same object ??? |
11895 | if (part.ParentGroup == thisgrp) | ||
11896 | continue; | ||
10800 | 11897 | ||
10801 | if (pa != null && pa.IsPhysical) | 11898 | if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY) |
10802 | { | 11899 | itemID = part.ParentGroup.UUID; |
10803 | if (!checkPhysical) | ||
10804 | continue; | ||
10805 | } | ||
10806 | else | 11900 | else |
10807 | { | 11901 | itemID = part.UUID; |
10808 | if (!checkNonPhysical) | ||
10809 | continue; | ||
10810 | } | ||
10811 | } | ||
10812 | 11902 | ||
10813 | refcount++; | 11903 | linkNum = part.LinkNum; |
10814 | if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY && entity is SceneObjectPart) | 11904 | } |
10815 | list.Add(((SceneObjectPart)entity).ParentGroup.UUID); | ||
10816 | else | 11905 | else |
10817 | list.Add(entity.UUID); | ||
10818 | |||
10819 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) | ||
10820 | { | 11906 | { |
10821 | if (entity is SceneObjectPart) | 11907 | ScenePresence sp = World.GetScenePresence(result.ConsumerID); |
10822 | list.Add(((SceneObjectPart)entity).LinkNum); | 11908 | /// It it a boy? a girl? |
10823 | else | 11909 | if (sp != null) |
10824 | list.Add(0); | 11910 | itemID = sp.UUID; |
10825 | } | 11911 | } |
10826 | 11912 | ||
10827 | list.Add(result.Pos); | 11913 | list.Add(new LSL_String(itemID.ToString())); |
11914 | list.Add(new LSL_String(result.Pos.ToString())); | ||
11915 | |||
11916 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) | ||
11917 | list.Add(new LSL_Integer(linkNum)); | ||
10828 | 11918 | ||
10829 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) | 11919 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) |
10830 | list.Add(result.Normal); | 11920 | list.Add(new LSL_Vector(result.Normal.X, result.Normal.Y, result.Normal.Z)); |
11921 | |||
11922 | values++; | ||
11923 | if (values >= count) | ||
11924 | break; | ||
10831 | } | 11925 | } |
10832 | 11926 | ||
10833 | list.Add(refcount); //The status code, either the # of contacts, RCERR_SIM_PERF_LOW, or RCERR_CAST_TIME_EXCEEDED | 11927 | list.Add(new LSL_Integer(values)); |
10834 | 11928 | ||
10835 | return list; | 11929 | return list; |
10836 | } | 11930 | } |
@@ -10870,7 +11964,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10870 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: | 11964 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: |
10871 | if (!isAccount) return 0; | 11965 | if (!isAccount) return 0; |
10872 | if (estate.HasAccess(id)) return 1; | 11966 | if (estate.HasAccess(id)) return 1; |
10873 | if (estate.IsBanned(id)) | 11967 | if (estate.IsBanned(id, World.GetUserFlags(id))) |
10874 | estate.RemoveBan(id); | 11968 | estate.RemoveBan(id); |
10875 | estate.AddEstateUser(id); | 11969 | estate.AddEstateUser(id); |
10876 | break; | 11970 | break; |
@@ -10889,14 +11983,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10889 | break; | 11983 | break; |
10890 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: | 11984 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: |
10891 | if (!isAccount) return 0; | 11985 | if (!isAccount) return 0; |
10892 | if (estate.IsBanned(id)) return 1; | 11986 | if (estate.IsBanned(id, World.GetUserFlags(id))) return 1; |
10893 | EstateBan ban = new EstateBan(); | 11987 | EstateBan ban = new EstateBan(); |
10894 | ban.EstateID = estate.EstateID; | 11988 | ban.EstateID = estate.EstateID; |
10895 | ban.BannedUserID = id; | 11989 | ban.BannedUserID = id; |
10896 | estate.AddBan(ban); | 11990 | estate.AddBan(ban); |
10897 | break; | 11991 | break; |
10898 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: | 11992 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: |
10899 | if (!isAccount || !estate.IsBanned(id)) return 0; | 11993 | if (!isAccount || !estate.IsBanned(id, World.GetUserFlags(id))) return 0; |
10900 | estate.RemoveBan(id); | 11994 | estate.RemoveBan(id); |
10901 | break; | 11995 | break; |
10902 | default: return 0; | 11996 | default: return 0; |
@@ -10925,7 +12019,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10925 | return 16384; | 12019 | return 16384; |
10926 | } | 12020 | } |
10927 | 12021 | ||
10928 | public LSL_Integer llGetUsedMemory() | 12022 | public virtual LSL_Integer llGetUsedMemory() |
10929 | { | 12023 | { |
10930 | m_host.AddScriptLPS(1); | 12024 | m_host.AddScriptLPS(1); |
10931 | // The value returned for LSO scripts in SL | 12025 | // The value returned for LSO scripts in SL |
@@ -10953,7 +12047,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10953 | public void llSetSoundQueueing(int queue) | 12047 | public void llSetSoundQueueing(int queue) |
10954 | { | 12048 | { |
10955 | m_host.AddScriptLPS(1); | 12049 | m_host.AddScriptLPS(1); |
10956 | NotImplemented("llSetSoundQueueing"); | ||
10957 | } | 12050 | } |
10958 | 12051 | ||
10959 | public void llCollisionSprite(string impact_sprite) | 12052 | public void llCollisionSprite(string impact_sprite) |
@@ -10965,10 +12058,270 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10965 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) | 12058 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) |
10966 | { | 12059 | { |
10967 | m_host.AddScriptLPS(1); | 12060 | m_host.AddScriptLPS(1); |
10968 | NotImplemented("llGodLikeRezObject"); | 12061 | |
12062 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
12063 | NotImplemented("llGodLikeRezObject"); | ||
12064 | |||
12065 | AssetBase rezAsset = World.AssetService.Get(inventory); | ||
12066 | if (rezAsset == null) | ||
12067 | { | ||
12068 | llSay(0, "Asset not found"); | ||
12069 | return; | ||
12070 | } | ||
12071 | |||
12072 | SceneObjectGroup group = null; | ||
12073 | |||
12074 | try | ||
12075 | { | ||
12076 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
12077 | group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
12078 | } | ||
12079 | catch | ||
12080 | { | ||
12081 | llSay(0, "Asset not found"); | ||
12082 | return; | ||
12083 | } | ||
12084 | |||
12085 | if (group == null) | ||
12086 | { | ||
12087 | llSay(0, "Asset not found"); | ||
12088 | return; | ||
12089 | } | ||
12090 | |||
12091 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
12092 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
12093 | |||
12094 | group.ResetIDs(); | ||
12095 | |||
12096 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
12097 | World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero); | ||
12098 | group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3); | ||
12099 | group.ScheduleGroupForFullUpdate(); | ||
12100 | |||
12101 | // objects rezzed with this method are die_at_edge by default. | ||
12102 | group.RootPart.SetDieAtEdge(true); | ||
12103 | |||
12104 | group.ResumeScripts(); | ||
12105 | |||
12106 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | ||
12107 | "object_rez", new Object[] { | ||
12108 | new LSL_String( | ||
12109 | group.RootPart.UUID.ToString()) }, | ||
12110 | new DetectParams[0])); | ||
12111 | } | ||
12112 | |||
12113 | public LSL_String llTransferLindenDollars(string destination, int amount) | ||
12114 | { | ||
12115 | UUID txn = UUID.Random(); | ||
12116 | |||
12117 | Util.FireAndForget(delegate(object x) | ||
12118 | { | ||
12119 | int replycode = 0; | ||
12120 | string replydata = destination + "," + amount.ToString(); | ||
12121 | |||
12122 | try | ||
12123 | { | ||
12124 | TaskInventoryItem item = m_item; | ||
12125 | if (item == null) | ||
12126 | { | ||
12127 | replydata = "SERVICE_ERROR"; | ||
12128 | return; | ||
12129 | } | ||
12130 | |||
12131 | m_host.AddScriptLPS(1); | ||
12132 | |||
12133 | if (item.PermsGranter == UUID.Zero) | ||
12134 | { | ||
12135 | replydata = "MISSING_PERMISSION_DEBIT"; | ||
12136 | return; | ||
12137 | } | ||
12138 | |||
12139 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) | ||
12140 | { | ||
12141 | replydata = "MISSING_PERMISSION_DEBIT"; | ||
12142 | return; | ||
12143 | } | ||
12144 | |||
12145 | UUID toID = new UUID(); | ||
12146 | |||
12147 | if (!UUID.TryParse(destination, out toID)) | ||
12148 | { | ||
12149 | replydata = "INVALID_AGENT"; | ||
12150 | return; | ||
12151 | } | ||
12152 | |||
12153 | IMoneyModule money = World.RequestModuleInterface<IMoneyModule>(); | ||
12154 | |||
12155 | if (money == null) | ||
12156 | { | ||
12157 | replydata = "TRANSFERS_DISABLED"; | ||
12158 | return; | ||
12159 | } | ||
12160 | |||
12161 | bool result = money.ObjectGiveMoney( | ||
12162 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | ||
12163 | |||
12164 | if (result) | ||
12165 | { | ||
12166 | replycode = 1; | ||
12167 | return; | ||
12168 | } | ||
12169 | |||
12170 | replydata = "LINDENDOLLAR_INSUFFICIENTFUNDS"; | ||
12171 | } | ||
12172 | finally | ||
12173 | { | ||
12174 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | ||
12175 | "transaction_result", new Object[] { | ||
12176 | new LSL_String(txn.ToString()), | ||
12177 | new LSL_Integer(replycode), | ||
12178 | new LSL_String(replydata) }, | ||
12179 | new DetectParams[0])); | ||
12180 | } | ||
12181 | }); | ||
12182 | |||
12183 | return txn.ToString(); | ||
10969 | } | 12184 | } |
10970 | 12185 | ||
10971 | #endregion | 12186 | #endregion |
12187 | |||
12188 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
12189 | { | ||
12190 | SceneObjectGroup group = m_host.ParentGroup; | ||
12191 | |||
12192 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) | ||
12193 | return; | ||
12194 | if (group.IsAttachment) | ||
12195 | return; | ||
12196 | |||
12197 | if (frames.Data.Length > 0) // We are getting a new motion | ||
12198 | { | ||
12199 | if (group.RootPart.KeyframeMotion != null) | ||
12200 | group.RootPart.KeyframeMotion.Stop(); | ||
12201 | group.RootPart.KeyframeMotion = null; | ||
12202 | |||
12203 | int idx = 0; | ||
12204 | |||
12205 | KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; | ||
12206 | KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; | ||
12207 | |||
12208 | while (idx < options.Data.Length) | ||
12209 | { | ||
12210 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
12211 | int remain = options.Data.Length - idx; | ||
12212 | |||
12213 | switch (option) | ||
12214 | { | ||
12215 | case ScriptBaseClass.KFM_MODE: | ||
12216 | if (remain < 1) | ||
12217 | break; | ||
12218 | int modeval = (int)options.GetLSLIntegerItem(idx++); | ||
12219 | switch(modeval) | ||
12220 | { | ||
12221 | case ScriptBaseClass.KFM_FORWARD: | ||
12222 | mode = KeyframeMotion.PlayMode.Forward; | ||
12223 | break; | ||
12224 | case ScriptBaseClass.KFM_REVERSE: | ||
12225 | mode = KeyframeMotion.PlayMode.Reverse; | ||
12226 | break; | ||
12227 | case ScriptBaseClass.KFM_LOOP: | ||
12228 | mode = KeyframeMotion.PlayMode.Loop; | ||
12229 | break; | ||
12230 | case ScriptBaseClass.KFM_PING_PONG: | ||
12231 | mode = KeyframeMotion.PlayMode.PingPong; | ||
12232 | break; | ||
12233 | } | ||
12234 | break; | ||
12235 | case ScriptBaseClass.KFM_DATA: | ||
12236 | if (remain < 1) | ||
12237 | break; | ||
12238 | int dataval = (int)options.GetLSLIntegerItem(idx++); | ||
12239 | data = (KeyframeMotion.DataFormat)dataval; | ||
12240 | break; | ||
12241 | } | ||
12242 | } | ||
12243 | |||
12244 | group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); | ||
12245 | |||
12246 | idx = 0; | ||
12247 | |||
12248 | int elemLength = 2; | ||
12249 | if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) | ||
12250 | elemLength = 3; | ||
12251 | |||
12252 | List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); | ||
12253 | while (idx < frames.Data.Length) | ||
12254 | { | ||
12255 | int remain = frames.Data.Length - idx; | ||
12256 | |||
12257 | if (remain < elemLength) | ||
12258 | break; | ||
12259 | |||
12260 | KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); | ||
12261 | frame.Position = null; | ||
12262 | frame.Rotation = null; | ||
12263 | |||
12264 | if ((data & KeyframeMotion.DataFormat.Translation) != 0) | ||
12265 | { | ||
12266 | LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); | ||
12267 | frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); | ||
12268 | } | ||
12269 | if ((data & KeyframeMotion.DataFormat.Rotation) != 0) | ||
12270 | { | ||
12271 | LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); | ||
12272 | frame.Rotation = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); | ||
12273 | } | ||
12274 | |||
12275 | float tempf = (float)frames.GetLSLFloatItem(idx++); | ||
12276 | frame.TimeMS = (int)(tempf * 1000.0f); | ||
12277 | |||
12278 | keyframes.Add(frame); | ||
12279 | } | ||
12280 | |||
12281 | group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); | ||
12282 | group.RootPart.KeyframeMotion.Start(); | ||
12283 | } | ||
12284 | else | ||
12285 | { | ||
12286 | if (group.RootPart.KeyframeMotion == null) | ||
12287 | return; | ||
12288 | |||
12289 | if (options.Data.Length == 0) | ||
12290 | { | ||
12291 | group.RootPart.KeyframeMotion.Stop(); | ||
12292 | return; | ||
12293 | } | ||
12294 | |||
12295 | int code = (int)options.GetLSLIntegerItem(0); | ||
12296 | |||
12297 | int idx = 0; | ||
12298 | |||
12299 | while (idx < options.Data.Length) | ||
12300 | { | ||
12301 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
12302 | int remain = options.Data.Length - idx; | ||
12303 | |||
12304 | switch (option) | ||
12305 | { | ||
12306 | case ScriptBaseClass.KFM_COMMAND: | ||
12307 | int cmd = (int)options.GetLSLIntegerItem(idx++); | ||
12308 | switch (cmd) | ||
12309 | { | ||
12310 | case ScriptBaseClass.KFM_CMD_PLAY: | ||
12311 | group.RootPart.KeyframeMotion.Start(); | ||
12312 | break; | ||
12313 | case ScriptBaseClass.KFM_CMD_STOP: | ||
12314 | group.RootPart.KeyframeMotion.Stop(); | ||
12315 | break; | ||
12316 | case ScriptBaseClass.KFM_CMD_PAUSE: | ||
12317 | group.RootPart.KeyframeMotion.Pause(); | ||
12318 | break; | ||
12319 | } | ||
12320 | break; | ||
12321 | } | ||
12322 | } | ||
12323 | } | ||
12324 | } | ||
10972 | } | 12325 | } |
10973 | 12326 | ||
10974 | public class NotecardCache | 12327 | 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 ad1a358..51ace1a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -138,6 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
138 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | 138 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; |
139 | internal float m_ScriptDelayFactor = 1.0f; | 139 | internal float m_ScriptDelayFactor = 1.0f; |
140 | internal float m_ScriptDistanceFactor = 1.0f; | 140 | internal float m_ScriptDistanceFactor = 1.0f; |
141 | internal bool m_debuggerSafe = false; | ||
141 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 142 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
142 | 143 | ||
143 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 144 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
@@ -145,6 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
145 | m_ScriptEngine = ScriptEngine; | 146 | m_ScriptEngine = ScriptEngine; |
146 | m_host = host; | 147 | m_host = host; |
147 | m_item = item; | 148 | m_item = item; |
149 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
148 | 150 | ||
149 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) | 151 | if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) |
150 | m_OSFunctionsEnabled = true; | 152 | m_OSFunctionsEnabled = true; |
@@ -206,7 +208,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
206 | 208 | ||
207 | internal void OSSLError(string msg) | 209 | internal void OSSLError(string msg) |
208 | { | 210 | { |
209 | throw new Exception("OSSL Runtime Error: " + msg); | 211 | if (m_debuggerSafe) |
212 | { | ||
213 | OSSLShoutError(msg); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | throw new Exception("OSSL Runtime Error: " + msg); | ||
218 | } | ||
210 | } | 219 | } |
211 | 220 | ||
212 | /// <summary> | 221 | /// <summary> |
@@ -920,18 +929,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
920 | if (target != null) | 929 | if (target != null) |
921 | { | 930 | { |
922 | UUID animID=UUID.Zero; | 931 | UUID animID=UUID.Zero; |
923 | lock (m_host.TaskInventory) | 932 | m_host.TaskInventory.LockItemsForRead(true); |
933 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
924 | { | 934 | { |
925 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 935 | if (inv.Value.Name == animation) |
926 | { | 936 | { |
927 | if (inv.Value.Name == animation) | 937 | if (inv.Value.Type == (int)AssetType.Animation) |
928 | { | 938 | animID = inv.Value.AssetID; |
929 | if (inv.Value.Type == (int)AssetType.Animation) | 939 | continue; |
930 | animID = inv.Value.AssetID; | ||
931 | continue; | ||
932 | } | ||
933 | } | 940 | } |
934 | } | 941 | } |
942 | m_host.TaskInventory.LockItemsForRead(false); | ||
935 | if (animID == UUID.Zero) | 943 | if (animID == UUID.Zero) |
936 | target.Animator.AddAnimation(animation, m_host.UUID); | 944 | target.Animator.AddAnimation(animation, m_host.UUID); |
937 | else | 945 | else |
@@ -958,18 +966,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
958 | if (target != null) | 966 | if (target != null) |
959 | { | 967 | { |
960 | UUID animID = UUID.Zero; | 968 | UUID animID = UUID.Zero; |
961 | lock (m_host.TaskInventory) | 969 | m_host.TaskInventory.LockItemsForRead(true); |
970 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
962 | { | 971 | { |
963 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 972 | if (inv.Value.Name == animation) |
964 | { | 973 | { |
965 | if (inv.Value.Name == animation) | 974 | if (inv.Value.Type == (int)AssetType.Animation) |
966 | { | 975 | animID = inv.Value.AssetID; |
967 | if (inv.Value.Type == (int)AssetType.Animation) | 976 | continue; |
968 | animID = inv.Value.AssetID; | ||
969 | continue; | ||
970 | } | ||
971 | } | 977 | } |
972 | } | 978 | } |
979 | m_host.TaskInventory.LockItemsForRead(false); | ||
973 | 980 | ||
974 | if (animID == UUID.Zero) | 981 | if (animID == UUID.Zero) |
975 | target.Animator.RemoveAnimation(animation); | 982 | target.Animator.RemoveAnimation(animation); |
@@ -1790,6 +1797,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1790 | 1797 | ||
1791 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) | 1798 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) |
1792 | { | 1799 | { |
1800 | m_host.TaskInventory.LockItemsForRead(true); | ||
1793 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1801 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1794 | { | 1802 | { |
1795 | if (item.Type == 7 && item.Name == notecardNameOrUuid) | 1803 | if (item.Type == 7 && item.Name == notecardNameOrUuid) |
@@ -1797,6 +1805,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1797 | assetID = item.AssetID; | 1805 | assetID = item.AssetID; |
1798 | } | 1806 | } |
1799 | } | 1807 | } |
1808 | m_host.TaskInventory.LockItemsForRead(false); | ||
1800 | } | 1809 | } |
1801 | 1810 | ||
1802 | if (assetID == UUID.Zero) | 1811 | if (assetID == UUID.Zero) |
@@ -2264,7 +2273,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2264 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 2273 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
2265 | m_host.AddScriptLPS(1); | 2274 | m_host.AddScriptLPS(1); |
2266 | 2275 | ||
2267 | return NpcCreate(firstname, lastname, position, notecard, false, false); | 2276 | return NpcCreate(firstname, lastname, position, notecard, true, false); |
2268 | } | 2277 | } |
2269 | 2278 | ||
2270 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) | 2279 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) |
@@ -2275,24 +2284,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2275 | return NpcCreate( | 2284 | return NpcCreate( |
2276 | firstname, lastname, position, notecard, | 2285 | firstname, lastname, position, notecard, |
2277 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, | 2286 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, |
2278 | (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | 2287 | false); |
2288 | // (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | ||
2279 | } | 2289 | } |
2280 | 2290 | ||
2281 | private LSL_Key NpcCreate( | 2291 | private LSL_Key NpcCreate( |
2282 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) | 2292 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) |
2283 | { | 2293 | { |
2294 | if (!owned) | ||
2295 | OSSLError("Unowned NPCs are unsupported"); | ||
2296 | |||
2297 | string groupTitle = String.Empty; | ||
2298 | |||
2299 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) | ||
2300 | return new LSL_Key(UUID.Zero.ToString()); | ||
2301 | |||
2302 | if (firstname != String.Empty || lastname != String.Empty) | ||
2303 | { | ||
2304 | if (firstname != "Shown outfit:") | ||
2305 | groupTitle = "- NPC -"; | ||
2306 | } | ||
2307 | |||
2284 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2308 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2285 | if (module != null) | 2309 | if (module != null) |
2286 | { | 2310 | { |
2287 | AvatarAppearance appearance = null; | 2311 | AvatarAppearance appearance = null; |
2288 | 2312 | ||
2289 | UUID id; | 2313 | // UUID id; |
2290 | if (UUID.TryParse(notecard, out id)) | 2314 | // if (UUID.TryParse(notecard, out id)) |
2291 | { | 2315 | // { |
2292 | ScenePresence clonePresence = World.GetScenePresence(id); | 2316 | // ScenePresence clonePresence = World.GetScenePresence(id); |
2293 | if (clonePresence != null) | 2317 | // if (clonePresence != null) |
2294 | appearance = clonePresence.Appearance; | 2318 | // appearance = clonePresence.Appearance; |
2295 | } | 2319 | // } |
2296 | 2320 | ||
2297 | if (appearance == null) | 2321 | if (appearance == null) |
2298 | { | 2322 | { |
@@ -2320,6 +2344,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2320 | World, | 2344 | World, |
2321 | appearance); | 2345 | appearance); |
2322 | 2346 | ||
2347 | ScenePresence sp; | ||
2348 | if (World.TryGetScenePresence(x, out sp)) | ||
2349 | { | ||
2350 | sp.Grouptitle = groupTitle; | ||
2351 | sp.SendAvatarDataToAllAgents(); | ||
2352 | } | ||
2323 | return new LSL_Key(x.ToString()); | 2353 | return new LSL_Key(x.ToString()); |
2324 | } | 2354 | } |
2325 | 2355 | ||
@@ -2611,16 +2641,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2611 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); | 2641 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); |
2612 | m_host.AddScriptLPS(1); | 2642 | m_host.AddScriptLPS(1); |
2613 | 2643 | ||
2614 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2644 | ManualResetEvent ev = new ManualResetEvent(false); |
2615 | if (module != null) | ||
2616 | { | ||
2617 | UUID npcId = new UUID(npc.m_string); | ||
2618 | 2645 | ||
2619 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2646 | Util.FireAndForget(delegate(object x) { |
2620 | return; | 2647 | try |
2648 | { | ||
2649 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2650 | if (module != null) | ||
2651 | { | ||
2652 | UUID npcId = new UUID(npc.m_string); | ||
2621 | 2653 | ||
2622 | module.DeleteNPC(npcId, World); | 2654 | ILandObject l = World.LandChannel.GetLandObject(m_host.GroupPosition.X, m_host.GroupPosition.Y); |
2623 | } | 2655 | if (l == null || m_host.OwnerID != l.LandData.OwnerID) |
2656 | { | ||
2657 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2658 | return; | ||
2659 | } | ||
2660 | |||
2661 | module.DeleteNPC(npcId, World); | ||
2662 | } | ||
2663 | } | ||
2664 | finally | ||
2665 | { | ||
2666 | ev.Set(); | ||
2667 | } | ||
2668 | }); | ||
2669 | ev.WaitOne(); | ||
2624 | } | 2670 | } |
2625 | 2671 | ||
2626 | public void osNpcPlayAnimation(LSL_Key npc, string animation) | 2672 | public void osNpcPlayAnimation(LSL_Key npc, string animation) |
@@ -3154,4 +3200,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3154 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | 3200 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); |
3155 | } | 3201 | } |
3156 | } | 3202 | } |
3157 | } \ No newline at end of file | 3203 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 3844753..19f3ce1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -319,7 +319,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
319 | float dy; | 319 | float dy; |
320 | float dz; | 320 | float dz; |
321 | 321 | ||
322 | Quaternion q = SensePoint.GetWorldRotation(); | 322 | // Quaternion q = SensePoint.RotationOffset; |
323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | ||
323 | if (SensePoint.ParentGroup.IsAttachment) | 324 | if (SensePoint.ParentGroup.IsAttachment) |
324 | { | 325 | { |
325 | // In attachments, rotate the sensor cone with the | 326 | // In attachments, rotate the sensor cone with the |
@@ -333,7 +334,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
333 | // Position of a sensor in a child prim attached to an avatar | 334 | // Position of a sensor in a child prim attached to an avatar |
334 | // will be still wrong. | 335 | // will be still wrong. |
335 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 336 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
336 | q = avatar.Rotation * q; | 337 | fromRegionPos = avatar.AbsolutePosition; |
338 | q = avatar.Rotation; | ||
337 | } | 339 | } |
338 | 340 | ||
339 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 341 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -463,7 +465,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
463 | // Position of a sensor in a child prim attached to an avatar | 465 | // Position of a sensor in a child prim attached to an avatar |
464 | // will be still wrong. | 466 | // will be still wrong. |
465 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 467 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
466 | q = avatar.Rotation * q; | 468 | if (avatar == null) |
469 | return sensedEntities; | ||
470 | fromRegionPos = avatar.AbsolutePosition; | ||
471 | q = avatar.Rotation; | ||
467 | } | 472 | } |
468 | 473 | ||
469 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 474 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index bc63030..9ee6946 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -118,25 +118,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
118 | if (Timers.Count == 0) | 118 | if (Timers.Count == 0) |
119 | return; | 119 | return; |
120 | 120 | ||
121 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
121 | lock (TimerListLock) | 122 | lock (TimerListLock) |
122 | { | 123 | { |
123 | // Go through all timers | 124 | // Go through all timers |
124 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 125 | tvals = Timers.Values; |
125 | foreach (TimerClass ts in tvals) | 126 | } |
127 | |||
128 | foreach (TimerClass ts in tvals) | ||
129 | { | ||
130 | // Time has passed? | ||
131 | if (ts.next < DateTime.Now.Ticks) | ||
126 | { | 132 | { |
127 | // Time has passed? | 133 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
128 | if (ts.next < DateTime.Now.Ticks) | 134 | // Add it to queue |
129 | { | 135 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
130 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 136 | new EventParams("timer", new Object[0], |
131 | // Add it to queue | 137 | new DetectParams[0])); |
132 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 138 | // set next interval |
133 | new EventParams("timer", new Object[0], | 139 | |
134 | new DetectParams[0])); | 140 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
135 | // set next interval | 141 | ts.next = DateTime.Now.Ticks + ts.interval; |
136 | |||
137 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
138 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
139 | } | ||
140 | } | 142 | } |
141 | } | 143 | } |
142 | } | 144 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..ab215f3 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
40 | { | ||
41 | public interface ICM_Api | ||
42 | { | ||
43 | string cmDetectedCountry(int num); | ||
44 | string cmGetAgentCountry(key key); | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 7f5d1fe..048124d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -126,6 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
126 | LSL_Float llGetEnergy(); | 126 | LSL_Float llGetEnergy(); |
127 | LSL_Vector llGetForce(); | 127 | LSL_Vector llGetForce(); |
128 | LSL_Integer llGetFreeMemory(); | 128 | LSL_Integer llGetFreeMemory(); |
129 | LSL_Integer llGetUsedMemory(); | ||
129 | LSL_Integer llGetFreeURLs(); | 130 | LSL_Integer llGetFreeURLs(); |
130 | LSL_Vector llGetGeometricCenter(); | 131 | LSL_Vector llGetGeometricCenter(); |
131 | LSL_Float llGetGMTclock(); | 132 | LSL_Float llGetGMTclock(); |
@@ -149,6 +150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
149 | LSL_Vector llGetLocalPos(); | 150 | LSL_Vector llGetLocalPos(); |
150 | LSL_Rotation llGetLocalRot(); | 151 | LSL_Rotation llGetLocalRot(); |
151 | LSL_Float llGetMass(); | 152 | LSL_Float llGetMass(); |
153 | LSL_Float llGetMassMKS(); | ||
152 | LSL_Integer llGetMemoryLimit(); | 154 | LSL_Integer llGetMemoryLimit(); |
153 | void llGetNextEmail(string address, string subject); | 155 | void llGetNextEmail(string address, string subject); |
154 | LSL_String llGetNotecardLine(string name, int line); | 156 | LSL_String llGetNotecardLine(string name, int line); |
@@ -202,12 +204,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
202 | LSL_String llGetTimestamp(); | 204 | LSL_String llGetTimestamp(); |
203 | LSL_Vector llGetTorque(); | 205 | LSL_Vector llGetTorque(); |
204 | LSL_Integer llGetUnixTime(); | 206 | LSL_Integer llGetUnixTime(); |
205 | LSL_Integer llGetUsedMemory(); | ||
206 | LSL_Vector llGetVel(); | 207 | LSL_Vector llGetVel(); |
207 | LSL_Float llGetWallclock(); | 208 | LSL_Float llGetWallclock(); |
208 | void llGiveInventory(string destination, string inventory); | 209 | void llGiveInventory(string destination, string inventory); |
209 | void llGiveInventoryList(string destination, string category, LSL_List inventory); | 210 | void llGiveInventoryList(string destination, string category, LSL_List inventory); |
210 | LSL_Integer llGiveMoney(string destination, int amount); | 211 | LSL_Integer llGiveMoney(string destination, int amount); |
212 | LSL_String llTransferLindenDollars(string destination, int amount); | ||
211 | void llGodLikeRezObject(string inventory, LSL_Vector pos); | 213 | void llGodLikeRezObject(string inventory, LSL_Vector pos); |
212 | LSL_Float llGround(LSL_Vector offset); | 214 | LSL_Float llGround(LSL_Vector offset); |
213 | LSL_Vector llGroundContour(LSL_Vector offset); | 215 | LSL_Vector llGroundContour(LSL_Vector offset); |
@@ -355,6 +357,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
355 | void llSetParcelMusicURL(string url); | 357 | void llSetParcelMusicURL(string url); |
356 | void llSetPayPrice(int price, LSL_List quick_pay_buttons); | 358 | void llSetPayPrice(int price, LSL_List quick_pay_buttons); |
357 | void llSetPos(LSL_Vector pos); | 359 | void llSetPos(LSL_Vector pos); |
360 | LSL_Integer llSetRegionPos(LSL_Vector pos); | ||
358 | LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); | 361 | LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); |
359 | void llSetPrimitiveParams(LSL_List rules); | 362 | void llSetPrimitiveParams(LSL_List rules); |
360 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); | 363 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); |
@@ -403,6 +406,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
403 | void llTargetOmega(LSL_Vector axis, double spinrate, double gain); | 406 | void llTargetOmega(LSL_Vector axis, double spinrate, double gain); |
404 | void llTargetRemove(int number); | 407 | void llTargetRemove(int number); |
405 | void llTeleportAgentHome(string agent); | 408 | void llTeleportAgentHome(string agent); |
409 | void llTeleportAgent(string agent, string simname, LSL_Vector pos, LSL_Vector lookAt); | ||
406 | void llTextBox(string avatar, string message, int chat_channel); | 410 | void llTextBox(string avatar, string message, int chat_channel); |
407 | LSL_String llToLower(string source); | 411 | LSL_String llToLower(string source); |
408 | LSL_String llToUpper(string source); | 412 | LSL_String llToUpper(string source); |
@@ -419,9 +423,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
419 | LSL_Vector llWind(LSL_Vector offset); | 423 | LSL_Vector llWind(LSL_Vector offset); |
420 | LSL_String llXorBase64Strings(string str1, string str2); | 424 | LSL_String llXorBase64Strings(string str1, string str2); |
421 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 425 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
422 | void print(string str); | 426 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); |
427 | void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); | ||
423 | 428 | ||
424 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 429 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
425 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 430 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
431 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); | ||
426 | } | 432 | } |
427 | } | 433 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index e92518d..7382495 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
85 | // Avatar Info Commands | 85 | // Avatar Info Commands |
86 | string osGetAgentIP(string agent); | 86 | string osGetAgentIP(string agent); |
87 | LSL_List osGetAgents(); | 87 | LSL_List osGetAgents(); |
88 | 88 | ||
89 | // Teleport commands | 89 | // Teleport commands |
90 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 90 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
91 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 91 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..4132dfa --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public ICM_Api m_CM_Functions; | ||
52 | |||
53 | public void ApiTypeCM(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is ICM_Api)) | ||
56 | return; | ||
57 | |||
58 | m_CM_Functions = (ICM_Api)api; | ||
59 | } | ||
60 | |||
61 | public string cmDetectedCountry(int num) | ||
62 | { | ||
63 | return m_CM_Functions.cmDetectedCountry(num); | ||
64 | } | ||
65 | |||
66 | public string cmGetAgentCountry(key key) | ||
67 | { | ||
68 | return m_CM_Functions.cmGetAgentCountry(key); | ||
69 | } | ||
70 | } | ||
71 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 9615315..943d7a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
132 | return (eventFlags); | 133 | return (eventFlags); |
133 | } | 134 | } |
134 | 135 | ||
136 | [DebuggerNonUserCode] | ||
135 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 137 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
136 | { | 138 | { |
137 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 139 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index b6c21e6..5c6ad8a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -94,6 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
94 | public const int AGENT_CROUCHING = 1024; | 94 | public const int AGENT_CROUCHING = 1024; |
95 | public const int AGENT_BUSY = 2048; | 95 | public const int AGENT_BUSY = 2048; |
96 | public const int AGENT_ALWAYS_RUN = 4096; | 96 | public const int AGENT_ALWAYS_RUN = 4096; |
97 | public const int AGENT_MALE = 8192; | ||
97 | 98 | ||
98 | //Particle Systems | 99 | //Particle Systems |
99 | public const int PSYS_PART_INTERP_COLOR_MASK = 1; | 100 | public const int PSYS_PART_INTERP_COLOR_MASK = 1; |
@@ -282,6 +283,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
282 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART | 283 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART |
283 | public const int CHANGED_MEDIA = 2048; | 284 | public const int CHANGED_MEDIA = 2048; |
284 | public const int CHANGED_ANIMATION = 16384; | 285 | public const int CHANGED_ANIMATION = 16384; |
286 | public const int CHANGED_POSITION = 32768; | ||
285 | public const int TYPE_INVALID = 0; | 287 | public const int TYPE_INVALID = 0; |
286 | public const int TYPE_INTEGER = 1; | 288 | public const int TYPE_INTEGER = 1; |
287 | public const int TYPE_FLOAT = 2; | 289 | public const int TYPE_FLOAT = 2; |
@@ -586,6 +588,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
586 | public const int PRIM_MEDIA_PERM_OWNER = 1; | 588 | public const int PRIM_MEDIA_PERM_OWNER = 1; |
587 | public const int PRIM_MEDIA_PERM_GROUP = 2; | 589 | public const int PRIM_MEDIA_PERM_GROUP = 2; |
588 | public const int PRIM_MEDIA_PERM_ANYONE = 4; | 590 | public const int PRIM_MEDIA_PERM_ANYONE = 4; |
591 | |||
592 | public const int PRIM_PHYSICS_SHAPE_TYPE = 30; | ||
593 | public const int PRIM_PHYSICS_SHAPE_PRIM = 0; | ||
594 | public const int PRIM_PHYSICS_SHAPE_CONVEX = 2; | ||
595 | public const int PRIM_PHYSICS_SHAPE_NONE = 1; | ||
596 | |||
597 | public const int PRIM_PHYSICS_MATERIAL = 31; | ||
598 | public const int DENSITY = 1; | ||
599 | public const int FRICTION = 2; | ||
600 | public const int RESTITUTION = 4; | ||
601 | public const int GRAVITY_MULTIPLIER = 8; | ||
589 | 602 | ||
590 | // extra constants for llSetPrimMediaParams | 603 | // extra constants for llSetPrimMediaParams |
591 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); | 604 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); |
@@ -659,5 +672,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
659 | public static readonly LSLInteger RCERR_UNKNOWN = -1; | 672 | public static readonly LSLInteger RCERR_UNKNOWN = -1; |
660 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; | 673 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; |
661 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; | 674 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; |
675 | |||
676 | public const int KFM_MODE = 1; | ||
677 | public const int KFM_LOOP = 1; | ||
678 | public const int KFM_REVERSE = 3; | ||
679 | public const int KFM_FORWARD = 0; | ||
680 | public const int KFM_PING_PONG = 2; | ||
681 | public const int KFM_DATA = 2; | ||
682 | public const int KFM_TRANSLATION = 2; | ||
683 | public const int KFM_ROTATION = 1; | ||
684 | public const int KFM_COMMAND = 0; | ||
685 | public const int KFM_CMD_PLAY = 0; | ||
686 | public const int KFM_CMD_STOP = 1; | ||
687 | public const int KFM_CMD_PAUSE = 2; | ||
662 | } | 688 | } |
663 | } | 689 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index c0bf29c..2d23d30 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; |
@@ -164,6 +165,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
164 | m_LSL_Functions.llBreakLink(linknum); | 165 | m_LSL_Functions.llBreakLink(linknum); |
165 | } | 166 | } |
166 | 167 | ||
168 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | ||
169 | { | ||
170 | return m_LSL_Functions.llCastRay(start, end, options); | ||
171 | } | ||
172 | |||
167 | public LSL_Integer llCeil(double f) | 173 | public LSL_Integer llCeil(double f) |
168 | { | 174 | { |
169 | return m_LSL_Functions.llCeil(f); | 175 | return m_LSL_Functions.llCeil(f); |
@@ -314,6 +320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
314 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 320 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
315 | } | 321 | } |
316 | 322 | ||
323 | [DebuggerNonUserCode] | ||
317 | public void llDie() | 324 | public void llDie() |
318 | { | 325 | { |
319 | m_LSL_Functions.llDie(); | 326 | m_LSL_Functions.llDie(); |
@@ -474,6 +481,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
474 | return m_LSL_Functions.llGetFreeMemory(); | 481 | return m_LSL_Functions.llGetFreeMemory(); |
475 | } | 482 | } |
476 | 483 | ||
484 | public LSL_Integer llGetUsedMemory() | ||
485 | { | ||
486 | return m_LSL_Functions.llGetUsedMemory(); | ||
487 | } | ||
488 | |||
477 | public LSL_Integer llGetFreeURLs() | 489 | public LSL_Integer llGetFreeURLs() |
478 | { | 490 | { |
479 | return m_LSL_Functions.llGetFreeURLs(); | 491 | return m_LSL_Functions.llGetFreeURLs(); |
@@ -579,6 +591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
579 | return m_LSL_Functions.llGetMass(); | 591 | return m_LSL_Functions.llGetMass(); |
580 | } | 592 | } |
581 | 593 | ||
594 | public LSL_Float llGetMassMKS() | ||
595 | { | ||
596 | return m_LSL_Functions.llGetMassMKS(); | ||
597 | } | ||
598 | |||
582 | public LSL_Integer llGetMemoryLimit() | 599 | public LSL_Integer llGetMemoryLimit() |
583 | { | 600 | { |
584 | return m_LSL_Functions.llGetMemoryLimit(); | 601 | return m_LSL_Functions.llGetMemoryLimit(); |
@@ -844,11 +861,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
844 | return m_LSL_Functions.llGetUnixTime(); | 861 | return m_LSL_Functions.llGetUnixTime(); |
845 | } | 862 | } |
846 | 863 | ||
847 | public LSL_Integer llGetUsedMemory() | ||
848 | { | ||
849 | return m_LSL_Functions.llGetUsedMemory(); | ||
850 | } | ||
851 | |||
852 | public LSL_Vector llGetVel() | 864 | public LSL_Vector llGetVel() |
853 | { | 865 | { |
854 | return m_LSL_Functions.llGetVel(); | 866 | return m_LSL_Functions.llGetVel(); |
@@ -874,6 +886,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
874 | return m_LSL_Functions.llGiveMoney(destination, amount); | 886 | return m_LSL_Functions.llGiveMoney(destination, amount); |
875 | } | 887 | } |
876 | 888 | ||
889 | public LSL_String llTransferLindenDollars(string destination, int amount) | ||
890 | { | ||
891 | return m_LSL_Functions.llTransferLindenDollars(destination, amount); | ||
892 | } | ||
893 | |||
877 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) | 894 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) |
878 | { | 895 | { |
879 | m_LSL_Functions.llGodLikeRezObject(inventory, pos); | 896 | m_LSL_Functions.llGodLikeRezObject(inventory, pos); |
@@ -1598,6 +1615,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1598 | m_LSL_Functions.llSetPos(pos); | 1615 | m_LSL_Functions.llSetPos(pos); |
1599 | } | 1616 | } |
1600 | 1617 | ||
1618 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1619 | { | ||
1620 | return m_LSL_Functions.llSetRegionPos(pos); | ||
1621 | } | ||
1622 | |||
1601 | public void llSetPrimitiveParams(LSL_List rules) | 1623 | public void llSetPrimitiveParams(LSL_List rules) |
1602 | { | 1624 | { |
1603 | m_LSL_Functions.llSetPrimitiveParams(rules); | 1625 | m_LSL_Functions.llSetPrimitiveParams(rules); |
@@ -1833,6 +1855,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1833 | m_LSL_Functions.llTargetRemove(number); | 1855 | m_LSL_Functions.llTargetRemove(number); |
1834 | } | 1856 | } |
1835 | 1857 | ||
1858 | public void llTeleportAgent(string agent, string simname, LSL_Vector pos, LSL_Vector lookAt) | ||
1859 | { | ||
1860 | m_LSL_Functions.llTeleportAgent(agent, simname, pos, lookAt); | ||
1861 | } | ||
1862 | |||
1836 | public void llTeleportAgentHome(string agent) | 1863 | public void llTeleportAgentHome(string agent) |
1837 | { | 1864 | { |
1838 | m_LSL_Functions.llTeleportAgentHome(agent); | 1865 | m_LSL_Functions.llTeleportAgentHome(agent); |
@@ -1948,9 +1975,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1948 | return m_LSL_Functions.llClearLinkMedia(link, face); | 1975 | return m_LSL_Functions.llClearLinkMedia(link, face); |
1949 | } | 1976 | } |
1950 | 1977 | ||
1951 | public void print(string str) | 1978 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
1979 | { | ||
1980 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | ||
1981 | } | ||
1982 | |||
1983 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
1984 | { | ||
1985 | m_LSL_Functions.llSetKeyframedMotion(frames, options); | ||
1986 | } | ||
1987 | |||
1988 | public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density) | ||
1952 | { | 1989 | { |
1953 | m_LSL_Functions.print(str); | 1990 | m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); |
1954 | } | 1991 | } |
1955 | } | 1992 | } |
1956 | } | 1993 | } |
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); |