diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
22 files changed, 4107 insertions, 1041 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 036cb5d..df1bd8b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -28,9 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | ||
32 | using System.Threading; | 31 | using System.Threading; |
33 | using log4net; | ||
34 | using OpenMetaverse; | 32 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Monitoring; | 34 | using OpenSim.Framework.Monitoring; |
@@ -39,6 +37,8 @@ using OpenSim.Region.ScriptEngine.Interfaces; | |||
39 | using OpenSim.Region.ScriptEngine.Shared; | 37 | using OpenSim.Region.ScriptEngine.Shared; |
40 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 38 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
41 | using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; | 39 | using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; |
40 | using System.Reflection; | ||
41 | using log4net; | ||
42 | 42 | ||
43 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 43 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
44 | { | 44 | { |
@@ -269,6 +269,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
269 | /// <param name="itemID"></param> | 269 | /// <param name="itemID"></param> |
270 | public static void RemoveScript(IScriptEngine engine, uint localID, UUID itemID) | 270 | public static void RemoveScript(IScriptEngine engine, uint localID, UUID itemID) |
271 | { | 271 | { |
272 | // Remove a specific script | ||
272 | // m_log.DebugFormat("[ASYNC COMMAND MANAGER]: Removing facilities for script {0}", itemID); | 273 | // m_log.DebugFormat("[ASYNC COMMAND MANAGER]: Removing facilities for script {0}", itemID); |
273 | 274 | ||
274 | lock (staticLock) | 275 | lock (staticLock) |
@@ -282,7 +283,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
282 | // Remove from: HttpRequest | 283 | // Remove from: HttpRequest |
283 | IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>(); | 284 | IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>(); |
284 | if (iHttpReq != null) | 285 | if (iHttpReq != null) |
285 | iHttpReq.StopHttpRequestsForScript(itemID); | 286 | iHttpReq.StopHttpRequest(localID, itemID); |
286 | 287 | ||
287 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); | 288 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); |
288 | if (comms != null) | 289 | if (comms != null) |
@@ -386,6 +387,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
386 | } | 387 | } |
387 | } | 388 | } |
388 | 389 | ||
390 | public static void StateChange(IScriptEngine engine, uint localID, UUID itemID) | ||
391 | { | ||
392 | // Remove a specific script | ||
393 | |||
394 | // Remove dataserver events | ||
395 | m_Dataserver[engine].RemoveEvents(localID, itemID); | ||
396 | |||
397 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); | ||
398 | if (comms != null) | ||
399 | comms.DeleteListener(itemID); | ||
400 | |||
401 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); | ||
402 | if (xmlrpc != null) | ||
403 | { | ||
404 | xmlrpc.DeleteChannels(itemID); | ||
405 | xmlrpc.CancelSRDRequests(itemID); | ||
406 | } | ||
407 | |||
408 | // Remove Sensors | ||
409 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | ||
410 | |||
411 | } | ||
412 | |||
389 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) | 413 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) |
390 | { | 414 | { |
391 | List<Object> data = new List<Object>(); | 415 | List<Object> data = new List<Object>(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..fce8ff8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Threading; | ||
30 | using System.Reflection; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Runtime.Remoting.Lifetime; | ||
34 | using OpenMetaverse; | ||
35 | using Nini.Config; | ||
36 | using OpenSim; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.CoreModules.World.LightShare; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.ScriptEngine.Shared; | ||
42 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
44 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
45 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | |||
48 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
49 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
50 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
51 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
52 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
53 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
54 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
55 | |||
56 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
57 | { | ||
58 | [Serializable] | ||
59 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
60 | { | ||
61 | internal IScriptEngine m_ScriptEngine; | ||
62 | internal SceneObjectPart m_host; | ||
63 | internal TaskInventoryItem m_item; | ||
64 | internal bool m_CMFunctionsEnabled = false; | ||
65 | |||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) | ||
67 | { | ||
68 | m_ScriptEngine = ScriptEngine; | ||
69 | m_host = host; | ||
70 | m_item = item; | ||
71 | |||
72 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
73 | m_CMFunctionsEnabled = true; | ||
74 | } | ||
75 | |||
76 | public override Object InitializeLifetimeService() | ||
77 | { | ||
78 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
79 | |||
80 | if (lease.CurrentState == LeaseState.Initial) | ||
81 | { | ||
82 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
83 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
84 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
85 | } | ||
86 | return lease; | ||
87 | } | ||
88 | |||
89 | public Scene World | ||
90 | { | ||
91 | get { return m_ScriptEngine.World; } | ||
92 | } | ||
93 | |||
94 | public string cmDetectedCountry(int number) | ||
95 | { | ||
96 | m_host.AddScriptLPS(1); | ||
97 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); | ||
98 | if (detectedParams == null) | ||
99 | return String.Empty; | ||
100 | return detectedParams.Country; | ||
101 | } | ||
102 | |||
103 | public string cmGetAgentCountry(LSL_Key key) | ||
104 | { | ||
105 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
106 | return String.Empty; | ||
107 | |||
108 | UUID uuid; | ||
109 | |||
110 | if (!UUID.TryParse(key, out uuid)) | ||
111 | return String.Empty; | ||
112 | |||
113 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | ||
114 | return account.UserCountry; | ||
115 | } | ||
116 | } | ||
117 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7719f07..f637a1d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -24,21 +24,30 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | <<<<<<< HEAD | ||
31 | using System.Diagnostics; | 32 | using System.Diagnostics; |
32 | using System.Drawing; | 33 | using System.Drawing; |
33 | using System.Drawing.Imaging; | 34 | using System.Drawing.Imaging; |
35 | ======= | ||
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
37 | >>>>>>> avn/ubitvar | ||
34 | using System.Runtime.Remoting.Lifetime; | 38 | using System.Runtime.Remoting.Lifetime; |
35 | using System.Text; | 39 | using System.Text; |
36 | using System.Threading; | 40 | using System.Threading; |
37 | using System.Text.RegularExpressions; | 41 | using System.Text.RegularExpressions; |
42 | using System.Timers; | ||
38 | using Nini.Config; | 43 | using Nini.Config; |
39 | using log4net; | 44 | using log4net; |
40 | using OpenMetaverse; | 45 | using OpenMetaverse; |
46 | <<<<<<< HEAD | ||
41 | using OpenMetaverse.Assets; | 47 | using OpenMetaverse.Assets; |
48 | ======= | ||
49 | using OpenMetaverse.StructuredData; | ||
50 | >>>>>>> avn/ubitvar | ||
42 | using OpenMetaverse.Packets; | 51 | using OpenMetaverse.Packets; |
43 | using OpenMetaverse.Rendering; | 52 | using OpenMetaverse.Rendering; |
44 | using OpenSim; | 53 | using OpenSim; |
@@ -49,6 +58,7 @@ using OpenSim.Region.CoreModules.World.Land; | |||
49 | using OpenSim.Region.CoreModules.World.Terrain; | 58 | using OpenSim.Region.CoreModules.World.Terrain; |
50 | using OpenSim.Region.Framework.Interfaces; | 59 | using OpenSim.Region.Framework.Interfaces; |
51 | using OpenSim.Region.Framework.Scenes; | 60 | using OpenSim.Region.Framework.Scenes; |
61 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
52 | using OpenSim.Region.Framework.Scenes.Animation; | 62 | using OpenSim.Region.Framework.Scenes.Animation; |
53 | using OpenSim.Region.Framework.Scenes.Scripting; | 63 | using OpenSim.Region.Framework.Scenes.Scripting; |
54 | using OpenSim.Region.Physics.Manager; | 64 | using OpenSim.Region.Physics.Manager; |
@@ -72,6 +82,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | |||
72 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 82 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
73 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 83 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
74 | using System.Reflection; | 84 | using System.Reflection; |
85 | using Timer = System.Timers.Timer; | ||
75 | using System.Linq; | 86 | using System.Linq; |
76 | using PermissionMask = OpenSim.Framework.PermissionMask; | 87 | using PermissionMask = OpenSim.Framework.PermissionMask; |
77 | 88 | ||
@@ -120,7 +131,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
120 | protected int m_notecardLineReadCharsMax = 255; | 131 | protected int m_notecardLineReadCharsMax = 255; |
121 | protected int m_scriptConsoleChannel = 0; | 132 | protected int m_scriptConsoleChannel = 0; |
122 | protected bool m_scriptConsoleChannelEnabled = false; | 133 | protected bool m_scriptConsoleChannelEnabled = false; |
134 | protected bool m_debuggerSafe = false; | ||
123 | protected IUrlModule m_UrlModule = null; | 135 | protected IUrlModule m_UrlModule = null; |
136 | <<<<<<< HEAD | ||
124 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); | 137 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); |
125 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 138 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
126 | protected int m_sleepMsOnSetTexture = 200; | 139 | protected int m_sleepMsOnSetTexture = 200; |
@@ -241,6 +254,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
241 | protected static List<CastRayCall> m_castRayCalls = new List<CastRayCall>(); | 254 | protected static List<CastRayCall> m_castRayCalls = new List<CastRayCall>(); |
242 | protected bool m_useMeshCacheInCastRay = true; | 255 | protected bool m_useMeshCacheInCastRay = true; |
243 | protected static Dictionary<ulong, FacetedMesh> m_cachedMeshes = new Dictionary<ulong, FacetedMesh>(); | 256 | protected static Dictionary<ulong, FacetedMesh> m_cachedMeshes = new Dictionary<ulong, FacetedMesh>(); |
257 | ======= | ||
258 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | ||
259 | new Dictionary<UUID, UserInfoCacheEntry>(); | ||
260 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | ||
261 | protected ISoundModule m_SoundModule = null; | ||
262 | |||
263 | // protected Timer m_ShoutSayTimer; | ||
264 | protected int m_SayShoutCount = 0; | ||
265 | DateTime m_lastSayShoutCheck; | ||
266 | |||
267 | private Dictionary<string, string> MovementAnimationsForLSL = | ||
268 | new Dictionary<string, string> { | ||
269 | {"CROUCH", "Crouching"}, | ||
270 | {"CROUCHWALK", "CrouchWalking"}, | ||
271 | {"FALLDOWN", "Falling Down"}, | ||
272 | {"FLY", "Flying"}, | ||
273 | {"FLYSLOW", "FlyingSlow"}, | ||
274 | {"HOVER", "Hovering"}, | ||
275 | {"HOVER_UP", "Hovering Up"}, | ||
276 | {"HOVER_DOWN", "Hovering Down"}, | ||
277 | {"JUMP", "Jumping"}, | ||
278 | {"LAND", "Landing"}, | ||
279 | {"PREJUMP", "PreJumping"}, | ||
280 | {"RUN", "Running"}, | ||
281 | {"SIT","Sitting"}, | ||
282 | {"SITGROUND","Sitting on Ground"}, | ||
283 | {"STAND", "Standing"}, | ||
284 | {"STANDUP", "Standing Up"}, | ||
285 | {"STRIDE","Striding"}, | ||
286 | {"SOFT_LAND", "Soft Landing"}, | ||
287 | {"TURNLEFT", "Turning Left"}, | ||
288 | {"TURNRIGHT", "Turning Right"}, | ||
289 | {"WALK", "Walking"} | ||
290 | }; | ||
291 | >>>>>>> avn/ubitvar | ||
244 | 292 | ||
245 | //An array of HTTP/1.1 headers that are not allowed to be used | 293 | //An array of HTTP/1.1 headers that are not allowed to be used |
246 | //as custom headers by llHTTPRequest. | 294 | //as custom headers by llHTTPRequest. |
@@ -262,9 +310,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
262 | public void Initialize( | 310 | public void Initialize( |
263 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) | 311 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) |
264 | { | 312 | { |
313 | m_lastSayShoutCheck = DateTime.UtcNow; | ||
314 | |||
265 | m_ScriptEngine = scriptEngine; | 315 | m_ScriptEngine = scriptEngine; |
266 | m_host = host; | 316 | m_host = host; |
267 | m_item = item; | 317 | m_item = item; |
318 | <<<<<<< HEAD | ||
319 | ======= | ||
320 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
321 | m_coopSleepHandle = coopSleepHandle; | ||
322 | >>>>>>> avn/ubitvar | ||
268 | 323 | ||
269 | LoadConfig(); | 324 | LoadConfig(); |
270 | 325 | ||
@@ -422,6 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
422 | get { return m_ScriptEngine.World; } | 477 | get { return m_ScriptEngine.World; } |
423 | } | 478 | } |
424 | 479 | ||
480 | [DebuggerNonUserCode] | ||
425 | public void state(string newState) | 481 | public void state(string newState) |
426 | { | 482 | { |
427 | m_ScriptEngine.SetState(m_item.ItemID, newState); | 483 | m_ScriptEngine.SetState(m_item.ItemID, newState); |
@@ -431,6 +487,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
431 | /// Reset the named script. The script must be present | 487 | /// Reset the named script. The script must be present |
432 | /// in the same prim. | 488 | /// in the same prim. |
433 | /// </summary> | 489 | /// </summary> |
490 | [DebuggerNonUserCode] | ||
434 | public void llResetScript() | 491 | public void llResetScript() |
435 | { | 492 | { |
436 | m_host.AddScriptLPS(1); | 493 | m_host.AddScriptLPS(1); |
@@ -493,6 +550,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
493 | } | 550 | } |
494 | } | 551 | } |
495 | 552 | ||
553 | public List<ScenePresence> GetLinkAvatars(int linkType) | ||
554 | { | ||
555 | List<ScenePresence> ret = new List<ScenePresence>(); | ||
556 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
557 | return ret; | ||
558 | |||
559 | List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars(); | ||
560 | |||
561 | switch (linkType) | ||
562 | { | ||
563 | case ScriptBaseClass.LINK_SET: | ||
564 | return avs; | ||
565 | |||
566 | case ScriptBaseClass.LINK_ROOT: | ||
567 | return ret; | ||
568 | |||
569 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
570 | return avs; | ||
571 | |||
572 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
573 | return avs; | ||
574 | |||
575 | case ScriptBaseClass.LINK_THIS: | ||
576 | return ret; | ||
577 | |||
578 | default: | ||
579 | if (linkType < 0) | ||
580 | return ret; | ||
581 | |||
582 | int partCount = m_host.ParentGroup.GetPartCount(); | ||
583 | |||
584 | if (linkType <= partCount) | ||
585 | { | ||
586 | return ret; | ||
587 | } | ||
588 | else | ||
589 | { | ||
590 | linkType = linkType - partCount; | ||
591 | if (linkType > avs.Count) | ||
592 | { | ||
593 | return ret; | ||
594 | } | ||
595 | else | ||
596 | { | ||
597 | ret.Add(avs[linkType-1]); | ||
598 | return ret; | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | |||
496 | /// <summary> | 604 | /// <summary> |
497 | /// Get a given link entity from a linkset (linked objects and any sitting avatars). | 605 | /// Get a given link entity from a linkset (linked objects and any sitting avatars). |
498 | /// </summary> | 606 | /// </summary> |
@@ -572,6 +680,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
572 | public static List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType) | 680 | public static List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType) |
573 | { | 681 | { |
574 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 682 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
683 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
684 | return ret; | ||
575 | ret.Add(part); | 685 | ret.Add(part); |
576 | 686 | ||
577 | switch (linkType) | 687 | switch (linkType) |
@@ -771,31 +881,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
771 | 881 | ||
772 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 882 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
773 | 883 | ||
774 | /// <summary> | 884 | // Utility function for llRot2Euler |
775 | /// Convert an LSL rotation to a Euler vector. | 885 | |
776 | /// </summary> | 886 | // normalize an angle between -PI and PI (-180 to +180 degrees) |
777 | /// <remarks> | 887 | protected double NormalizeAngle(double angle) |
778 | /// Using algorithm based off http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf | ||
779 | /// to avoid issues with singularity and rounding with Y rotation of +/- PI/2 | ||
780 | /// </remarks> | ||
781 | /// <param name="r"></param> | ||
782 | /// <returns></returns> | ||
783 | public LSL_Vector llRot2Euler(LSL_Rotation r) | ||
784 | { | 888 | { |
785 | m_host.AddScriptLPS(1); | 889 | if (angle > -Math.PI && angle < Math.PI) |
890 | return angle; | ||
891 | |||
892 | int numPis = (int)(Math.PI / angle); | ||
893 | double remainder = angle - Math.PI * numPis; | ||
894 | if (numPis % 2 == 1) | ||
895 | return Math.PI - angle; | ||
896 | return remainder; | ||
897 | } | ||
786 | 898 | ||
787 | LSL_Vector v = new LSL_Vector(0.0, 0.0, 1.0) * r; // Z axis unit vector unaffected by Z rotation component of r. | 899 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
788 | double m = LSL_Vector.Mag(v); // Just in case v isn't normalized, need magnitude for Asin() operation later. | 900 | { |
789 | if (m == 0.0) return new LSL_Vector(); | 901 | m_host.AddScriptLPS(1); |
790 | double x = Math.Atan2(-v.y, v.z); | 902 | LSL_Vector eul = new LSL_Vector(); |
791 | double sin = v.x / m; | ||
792 | if (sin < -0.999999 || sin > 0.999999) x = 0.0; // Force X rotation to 0 at the singularities. | ||
793 | double y = Math.Asin(sin); | ||
794 | // Rotate X axis unit vector by r and unwind the X and Y rotations leaving only the Z rotation | ||
795 | 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))); | ||
796 | double z = Math.Atan2(v.y, v.x); | ||
797 | 903 | ||
798 | return new LSL_Vector(x, y, z); | 904 | double sqw = q1.s*q1.s; |
905 | double sqx = q1.x*q1.x; | ||
906 | double sqy = q1.z*q1.z; | ||
907 | double sqz = q1.y*q1.y; | ||
908 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor | ||
909 | double test = q1.x*q1.z + q1.y*q1.s; | ||
910 | if (test > 0.4999*unit) { // singularity at north pole | ||
911 | eul.z = 2 * Math.Atan2(q1.x,q1.s); | ||
912 | eul.y = Math.PI/2; | ||
913 | eul.x = 0; | ||
914 | return eul; | ||
915 | } | ||
916 | if (test < -0.4999*unit) { // singularity at south pole | ||
917 | eul.z = -2 * Math.Atan2(q1.x,q1.s); | ||
918 | eul.y = -Math.PI/2; | ||
919 | eul.x = 0; | ||
920 | return eul; | ||
921 | } | ||
922 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
923 | eul.y = Math.Asin(2*test/unit); | ||
924 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
925 | return eul; | ||
799 | } | 926 | } |
800 | 927 | ||
801 | /* From wiki: | 928 | /* From wiki: |
@@ -848,18 +975,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
848 | m_host.AddScriptLPS(1); | 975 | m_host.AddScriptLPS(1); |
849 | 976 | ||
850 | double x,y,z,s; | 977 | double x,y,z,s; |
851 | 978 | v.x *= 0.5; | |
852 | double c1 = Math.Cos(v.x * 0.5); | 979 | v.y *= 0.5; |
853 | double c2 = Math.Cos(v.y * 0.5); | 980 | v.z *= 0.5; |
854 | double c3 = Math.Cos(v.z * 0.5); | 981 | double c1 = Math.Cos(v.x); |
855 | double s1 = Math.Sin(v.x * 0.5); | 982 | double c2 = Math.Cos(v.y); |
856 | double s2 = Math.Sin(v.y * 0.5); | 983 | double c1c2 = c1 * c2; |
857 | double s3 = Math.Sin(v.z * 0.5); | 984 | double s1 = Math.Sin(v.x); |
858 | 985 | double s2 = Math.Sin(v.y); | |
859 | x = s1 * c2 * c3 + c1 * s2 * s3; | 986 | double s1s2 = s1 * s2; |
860 | y = c1 * s2 * c3 - s1 * c2 * s3; | 987 | double c1s2 = c1 * s2; |
861 | z = s1 * s2 * c3 + c1 * c2 * s3; | 988 | double s1c2 = s1 * c2; |
862 | s = c1 * c2 * c3 - s1 * s2 * s3; | 989 | double c3 = Math.Cos(v.z); |
990 | double s3 = Math.Sin(v.z); | ||
991 | |||
992 | x = s1c2 * c3 + c1s2 * s3; | ||
993 | y = c1s2 * c3 - s1c2 * s3; | ||
994 | z = s1s2 * c3 + c1c2 * s3; | ||
995 | s = c1c2 * c3 - s1s2 * s3; | ||
863 | 996 | ||
864 | return new LSL_Rotation(x, y, z, s); | 997 | return new LSL_Rotation(x, y, z, s); |
865 | } | 998 | } |
@@ -997,77 +1130,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
997 | { | 1130 | { |
998 | //A and B should both be normalized | 1131 | //A and B should both be normalized |
999 | m_host.AddScriptLPS(1); | 1132 | m_host.AddScriptLPS(1); |
1000 | LSL_Rotation rotBetween; | 1133 | /* This method is more accurate than the SL one, and thus causes problems |
1001 | // Check for zero vectors. If either is zero, return zero rotation. Otherwise, | 1134 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. |
1002 | // continue calculation. | 1135 | |
1003 | if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) | 1136 | double dotProduct = LSL_Vector.Dot(a, b); |
1137 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
1138 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | ||
1139 | double angle = Math.Acos(dotProduct / magProduct); | ||
1140 | LSL_Vector axis = LSL_Vector.Norm(crossProduct); | ||
1141 | double s = Math.Sin(angle / 2); | ||
1142 | |||
1143 | double x = axis.x * s; | ||
1144 | double y = axis.y * s; | ||
1145 | double z = axis.z * s; | ||
1146 | double w = Math.Cos(angle / 2); | ||
1147 | |||
1148 | if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w)) | ||
1149 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
1150 | |||
1151 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | ||
1152 | */ | ||
1153 | |||
1154 | // This method mimics the 180 errors found in SL | ||
1155 | // See www.euclideanspace.com... angleBetween | ||
1156 | LSL_Vector vec_a = a; | ||
1157 | LSL_Vector vec_b = b; | ||
1158 | |||
1159 | // Eliminate zero length | ||
1160 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
1161 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
1162 | if (vec_a_mag < 0.00001 || | ||
1163 | vec_b_mag < 0.00001) | ||
1004 | { | 1164 | { |
1005 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 1165 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
1006 | } | 1166 | } |
1007 | else | 1167 | |
1168 | // Normalize | ||
1169 | vec_a = llVecNorm(vec_a); | ||
1170 | vec_b = llVecNorm(vec_b); | ||
1171 | |||
1172 | // Calculate axis and rotation angle | ||
1173 | LSL_Vector axis = vec_a % vec_b; | ||
1174 | LSL_Float cos_theta = vec_a * vec_b; | ||
1175 | |||
1176 | // Check if parallel | ||
1177 | if (cos_theta > 0.99999) | ||
1008 | { | 1178 | { |
1009 | a = LSL_Vector.Norm(a); | 1179 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
1010 | b = LSL_Vector.Norm(b); | 1180 | } |
1011 | double dotProduct = LSL_Vector.Dot(a, b); | 1181 | |
1012 | // There are two degenerate cases possible. These are for vectors 180 or | 1182 | // Check if anti-parallel |
1013 | // 0 degrees apart. These have to be detected and handled individually. | 1183 | else if (cos_theta < -0.99999) |
1014 | // | 1184 | { |
1015 | // Check for vectors 180 degrees apart. | 1185 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); |
1016 | // A dot product of -1 would mean the angle between vectors is 180 degrees. | 1186 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); |
1017 | if (dotProduct < -0.9999999f) | 1187 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); |
1018 | { | 1188 | } |
1019 | // First assume X axis is orthogonal to the vectors. | 1189 | else // other rotation |
1020 | LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); | 1190 | { |
1021 | orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); | 1191 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; |
1022 | // Check for near zero vector. A very small non-zero number here will create | 1192 | axis = llVecNorm(axis); |
1023 | // a rotation in an undesired direction. | 1193 | double x, y, z, s, t; |
1024 | if (LSL_Vector.Mag(orthoVector) > 0.0001) | 1194 | s = Math.Cos(theta); |
1025 | { | 1195 | t = Math.Sin(theta); |
1026 | rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); | 1196 | x = axis.x * t; |
1027 | } | 1197 | y = axis.y * t; |
1028 | // If the magnitude of the vector was near zero, then assume the X axis is not | 1198 | z = axis.z * t; |
1029 | // orthogonal and use the Z axis instead. | 1199 | return new LSL_Rotation(x,y,z,s); |
1030 | else | ||
1031 | { | ||
1032 | // Set 180 z rotation. | ||
1033 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); | ||
1034 | } | ||
1035 | } | ||
1036 | // Check for parallel vectors. | ||
1037 | // A dot product of 1 would mean the angle between vectors is 0 degrees. | ||
1038 | else if (dotProduct > 0.9999999f) | ||
1039 | { | ||
1040 | // Set zero rotation. | ||
1041 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
1042 | } | ||
1043 | else | ||
1044 | { | ||
1045 | // All special checks have been performed so get the axis of rotation. | ||
1046 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | ||
1047 | // Quarternion s value is the length of the unit vector + dot product. | ||
1048 | double qs = 1.0 + dotProduct; | ||
1049 | rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); | ||
1050 | // Normalize the rotation. | ||
1051 | double mag = LSL_Rotation.Mag(rotBetween); | ||
1052 | // We shouldn't have to worry about a divide by zero here. The qs value will be | ||
1053 | // non-zero because we already know if we're here, then the dotProduct is not -1 so | ||
1054 | // qs will not be zero. Also, we've already handled the input vectors being zero so the | ||
1055 | // crossProduct vector should also not be zero. | ||
1056 | rotBetween.x = rotBetween.x / mag; | ||
1057 | rotBetween.y = rotBetween.y / mag; | ||
1058 | rotBetween.z = rotBetween.z / mag; | ||
1059 | rotBetween.s = rotBetween.s / mag; | ||
1060 | // Check for undefined values and set zero rotation if any found. This code might not actually be required | ||
1061 | // any longer since zero vectors are checked for at the top. | ||
1062 | if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) | ||
1063 | { | ||
1064 | rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
1065 | } | ||
1066 | } | ||
1067 | } | 1200 | } |
1068 | return rotBetween; | ||
1069 | } | 1201 | } |
1070 | 1202 | ||
1071 | public void llWhisper(int channelID, string text) | 1203 | public void llWhisper(int channelID, string text) |
1072 | { | 1204 | { |
1073 | m_host.AddScriptLPS(1); | 1205 | m_host.AddScriptLPS(1); |
@@ -1083,10 +1215,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1083 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); | 1215 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); |
1084 | } | 1216 | } |
1085 | 1217 | ||
1218 | private void CheckSayShoutTime() | ||
1219 | { | ||
1220 | DateTime now = DateTime.UtcNow; | ||
1221 | if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec | ||
1222 | { | ||
1223 | m_lastSayShoutCheck = now; | ||
1224 | m_SayShoutCount = 0; | ||
1225 | } | ||
1226 | else | ||
1227 | m_SayShoutCount++; | ||
1228 | } | ||
1229 | |||
1086 | public void llSay(int channelID, string text) | 1230 | public void llSay(int channelID, string text) |
1087 | { | 1231 | { |
1088 | m_host.AddScriptLPS(1); | 1232 | m_host.AddScriptLPS(1); |
1089 | 1233 | ||
1234 | if (channelID == 0) | ||
1235 | // m_SayShoutCount++; | ||
1236 | CheckSayShoutTime(); | ||
1237 | |||
1238 | if (m_SayShoutCount >= 11) | ||
1239 | ScriptSleep(2000); | ||
1240 | |||
1090 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) | 1241 | if (m_scriptConsoleChannelEnabled && (channelID == m_scriptConsoleChannel)) |
1091 | { | 1242 | { |
1092 | Console.WriteLine(text); | 1243 | Console.WriteLine(text); |
@@ -1109,6 +1260,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1109 | { | 1260 | { |
1110 | m_host.AddScriptLPS(1); | 1261 | m_host.AddScriptLPS(1); |
1111 | 1262 | ||
1263 | if (channelID == 0) | ||
1264 | // m_SayShoutCount++; | ||
1265 | CheckSayShoutTime(); | ||
1266 | |||
1267 | if (m_SayShoutCount >= 11) | ||
1268 | ScriptSleep(2000); | ||
1269 | |||
1112 | if (text.Length > 1023) | 1270 | if (text.Length > 1023) |
1113 | text = text.Substring(0, 1023); | 1271 | text = text.Substring(0, 1023); |
1114 | 1272 | ||
@@ -1143,16 +1301,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1143 | 1301 | ||
1144 | public void llRegionSayTo(string target, int channel, string msg) | 1302 | public void llRegionSayTo(string target, int channel, string msg) |
1145 | { | 1303 | { |
1304 | string error = String.Empty; | ||
1305 | |||
1146 | if (msg.Length > 1023) | 1306 | if (msg.Length > 1023) |
1147 | msg = msg.Substring(0, 1023); | 1307 | msg = msg.Substring(0, 1023); |
1148 | 1308 | ||
1149 | m_host.AddScriptLPS(1); | 1309 | m_host.AddScriptLPS(1); |
1150 | 1310 | ||
1151 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
1152 | { | ||
1153 | return; | ||
1154 | } | ||
1155 | |||
1156 | UUID TargetID; | 1311 | UUID TargetID; |
1157 | UUID.TryParse(target, out TargetID); | 1312 | UUID.TryParse(target, out TargetID); |
1158 | 1313 | ||
@@ -1161,7 +1316,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1161 | 1316 | ||
1162 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 1317 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
1163 | if (wComm != null) | 1318 | if (wComm != null) |
1164 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); | 1319 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) |
1320 | LSLError(error); | ||
1165 | } | 1321 | } |
1166 | 1322 | ||
1167 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 1323 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -1417,10 +1573,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1417 | return detectedParams.TouchUV; | 1573 | return detectedParams.TouchUV; |
1418 | } | 1574 | } |
1419 | 1575 | ||
1576 | [DebuggerNonUserCode] | ||
1420 | public virtual void llDie() | 1577 | public virtual void llDie() |
1421 | { | 1578 | { |
1422 | m_host.AddScriptLPS(1); | 1579 | m_host.AddScriptLPS(1); |
1423 | throw new SelfDeleteException(); | 1580 | if (!m_host.ParentGroup.IsAttachment) throw new SelfDeleteException(); |
1424 | } | 1581 | } |
1425 | 1582 | ||
1426 | public LSL_Float llGround(LSL_Vector offset) | 1583 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1491,6 +1648,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1491 | 1648 | ||
1492 | public void llSetStatus(int status, int value) | 1649 | public void llSetStatus(int status, int value) |
1493 | { | 1650 | { |
1651 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1652 | return; | ||
1494 | m_host.AddScriptLPS(1); | 1653 | m_host.AddScriptLPS(1); |
1495 | 1654 | ||
1496 | int statusrotationaxis = 0; | 1655 | int statusrotationaxis = 0; |
@@ -1502,6 +1661,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1502 | SceneObjectGroup group = m_host.ParentGroup; | 1661 | SceneObjectGroup group = m_host.ParentGroup; |
1503 | bool allow = true; | 1662 | bool allow = true; |
1504 | 1663 | ||
1664 | int maxprims = World.m_linksetPhysCapacity; | ||
1665 | bool checkShape = (maxprims > 0 && group.PrimCount > maxprims); | ||
1666 | |||
1505 | foreach (SceneObjectPart part in group.Parts) | 1667 | foreach (SceneObjectPart part in group.Parts) |
1506 | { | 1668 | { |
1507 | if (part.Scale.X > World.m_maxPhys || part.Scale.Y > World.m_maxPhys || part.Scale.Z > World.m_maxPhys) | 1669 | if (part.Scale.X > World.m_maxPhys || part.Scale.Y > World.m_maxPhys || part.Scale.Z > World.m_maxPhys) |
@@ -1509,11 +1671,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1509 | allow = false; | 1671 | allow = false; |
1510 | break; | 1672 | break; |
1511 | } | 1673 | } |
1674 | if (checkShape && part.PhysicsShapeType != (byte)PhysicsShapeType.None) | ||
1675 | { | ||
1676 | if (--maxprims < 0) | ||
1677 | { | ||
1678 | allow = false; | ||
1679 | break; | ||
1680 | } | ||
1681 | } | ||
1512 | } | 1682 | } |
1513 | 1683 | ||
1514 | if (!allow) | 1684 | if (!allow) |
1515 | return; | 1685 | return; |
1516 | 1686 | ||
1687 | if (m_host.ParentGroup.RootPart.PhysActor != null && | ||
1688 | m_host.ParentGroup.RootPart.PhysActor.IsPhysical) | ||
1689 | return; | ||
1690 | |||
1517 | m_host.ScriptSetPhysicsStatus(true); | 1691 | m_host.ScriptSetPhysicsStatus(true); |
1518 | } | 1692 | } |
1519 | else | 1693 | else |
@@ -1712,12 +1886,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1712 | { | 1886 | { |
1713 | m_host.AddScriptLPS(1); | 1887 | m_host.AddScriptLPS(1); |
1714 | 1888 | ||
1889 | SetColor(m_host, color, face); | ||
1890 | } | ||
1891 | |||
1892 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1893 | { | ||
1894 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1895 | return; | ||
1896 | |||
1897 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1898 | Color4 texcolor; | ||
1899 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1900 | { | ||
1901 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1902 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1903 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1904 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1905 | tex.FaceTextures[face].RGBA = texcolor; | ||
1906 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1907 | return; | ||
1908 | } | ||
1909 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1910 | { | ||
1911 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1912 | { | ||
1913 | if (tex.FaceTextures[i] != null) | ||
1914 | { | ||
1915 | texcolor = tex.FaceTextures[i].RGBA; | ||
1916 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1917 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1918 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1919 | tex.FaceTextures[i].RGBA = texcolor; | ||
1920 | } | ||
1921 | texcolor = tex.DefaultTexture.RGBA; | ||
1922 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1923 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1924 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1925 | tex.DefaultTexture.RGBA = texcolor; | ||
1926 | } | ||
1927 | part.UpdateTextureEntry(tex.GetBytes()); | ||
1928 | return; | ||
1929 | } | ||
1930 | |||
1715 | if (face == ScriptBaseClass.ALL_SIDES) | 1931 | if (face == ScriptBaseClass.ALL_SIDES) |
1716 | face = SceneObjectPart.ALL_SIDES; | 1932 | face = SceneObjectPart.ALL_SIDES; |
1717 | 1933 | ||
1718 | m_host.SetFaceColorAlpha(face, color, null); | 1934 | m_host.SetFaceColorAlpha(face, color, null); |
1719 | } | 1935 | } |
1720 | 1936 | ||
1937 | /* | ||
1721 | public void llSetContentType(LSL_Key id, LSL_Integer type) | 1938 | public void llSetContentType(LSL_Key id, LSL_Integer type) |
1722 | { | 1939 | { |
1723 | m_host.AddScriptLPS(1); | 1940 | m_host.AddScriptLPS(1); |
@@ -1784,9 +2001,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1784 | break; | 2001 | break; |
1785 | } | 2002 | } |
1786 | } | 2003 | } |
2004 | */ | ||
1787 | 2005 | ||
1788 | public void SetTexGen(SceneObjectPart part, int face,int style) | 2006 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1789 | { | 2007 | { |
2008 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2009 | return; | ||
2010 | |||
1790 | Primitive.TextureEntry tex = part.Shape.Textures; | 2011 | Primitive.TextureEntry tex = part.Shape.Textures; |
1791 | MappingType textype; | 2012 | MappingType textype; |
1792 | textype = MappingType.Default; | 2013 | textype = MappingType.Default; |
@@ -1817,6 +2038,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1817 | 2038 | ||
1818 | public void SetGlow(SceneObjectPart part, int face, float glow) | 2039 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1819 | { | 2040 | { |
2041 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2042 | return; | ||
2043 | |||
1820 | Primitive.TextureEntry tex = part.Shape.Textures; | 2044 | Primitive.TextureEntry tex = part.Shape.Textures; |
1821 | if (face >= 0 && face < GetNumberOfSides(part)) | 2045 | if (face >= 0 && face < GetNumberOfSides(part)) |
1822 | { | 2046 | { |
@@ -1842,6 +2066,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1842 | 2066 | ||
1843 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 2067 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1844 | { | 2068 | { |
2069 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2070 | return; | ||
1845 | 2071 | ||
1846 | Shininess sval = new Shininess(); | 2072 | Shininess sval = new Shininess(); |
1847 | 2073 | ||
@@ -1892,6 +2118,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1892 | 2118 | ||
1893 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 2119 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1894 | { | 2120 | { |
2121 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2122 | return; | ||
2123 | |||
1895 | Primitive.TextureEntry tex = part.Shape.Textures; | 2124 | Primitive.TextureEntry tex = part.Shape.Textures; |
1896 | if (face >= 0 && face < GetNumberOfSides(part)) | 2125 | if (face >= 0 && face < GetNumberOfSides(part)) |
1897 | { | 2126 | { |
@@ -1952,13 +2181,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1952 | m_host.AddScriptLPS(1); | 2181 | m_host.AddScriptLPS(1); |
1953 | 2182 | ||
1954 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 2183 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1955 | 2184 | if (parts.Count > 0) | |
1956 | foreach (SceneObjectPart part in parts) | 2185 | { |
1957 | SetAlpha(part, alpha, face); | 2186 | try |
2187 | { | ||
2188 | foreach (SceneObjectPart part in parts) | ||
2189 | SetAlpha(part, alpha, face); | ||
2190 | } | ||
2191 | finally | ||
2192 | { | ||
2193 | } | ||
2194 | } | ||
1958 | } | 2195 | } |
1959 | 2196 | ||
1960 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 2197 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1961 | { | 2198 | { |
2199 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2200 | return; | ||
2201 | |||
1962 | Primitive.TextureEntry tex = part.Shape.Textures; | 2202 | Primitive.TextureEntry tex = part.Shape.Textures; |
1963 | Color4 texcolor; | 2203 | Color4 texcolor; |
1964 | if (face >= 0 && face < GetNumberOfSides(part)) | 2204 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -2011,7 +2251,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2011 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 2251 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
2012 | float wind, float tension, LSL_Vector Force) | 2252 | float wind, float tension, LSL_Vector Force) |
2013 | { | 2253 | { |
2014 | if (part == null) | 2254 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2015 | return; | 2255 | return; |
2016 | 2256 | ||
2017 | if (flexi) | 2257 | if (flexi) |
@@ -2052,7 +2292,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2052 | /// <param name="falloff"></param> | 2292 | /// <param name="falloff"></param> |
2053 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 2293 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
2054 | { | 2294 | { |
2055 | if (part == null) | 2295 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2056 | return; | 2296 | return; |
2057 | 2297 | ||
2058 | if (light) | 2298 | if (light) |
@@ -2085,11 +2325,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2085 | Primitive.TextureEntry tex = part.Shape.Textures; | 2325 | Primitive.TextureEntry tex = part.Shape.Textures; |
2086 | Color4 texcolor; | 2326 | Color4 texcolor; |
2087 | LSL_Vector rgb = new LSL_Vector(); | 2327 | LSL_Vector rgb = new LSL_Vector(); |
2328 | int nsides = GetNumberOfSides(part); | ||
2329 | |||
2088 | if (face == ScriptBaseClass.ALL_SIDES) | 2330 | if (face == ScriptBaseClass.ALL_SIDES) |
2089 | { | 2331 | { |
2090 | int i; | 2332 | int i; |
2091 | 2333 | for (i = 0; i < nsides; i++) | |
2092 | for (i = 0 ; i < GetNumberOfSides(part); i++) | ||
2093 | { | 2334 | { |
2094 | texcolor = tex.GetFace((uint)i).RGBA; | 2335 | texcolor = tex.GetFace((uint)i).RGBA; |
2095 | rgb.x += texcolor.R; | 2336 | rgb.x += texcolor.R; |
@@ -2097,14 +2338,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2097 | rgb.z += texcolor.B; | 2338 | rgb.z += texcolor.B; |
2098 | } | 2339 | } |
2099 | 2340 | ||
2100 | rgb.x /= (float)GetNumberOfSides(part); | 2341 | float invnsides = 1.0f / (float)nsides; |
2101 | rgb.y /= (float)GetNumberOfSides(part); | 2342 | |
2102 | rgb.z /= (float)GetNumberOfSides(part); | 2343 | rgb.x *= invnsides; |
2344 | rgb.y *= invnsides; | ||
2345 | rgb.z *= invnsides; | ||
2103 | 2346 | ||
2104 | return rgb; | 2347 | return rgb; |
2105 | } | 2348 | } |
2106 | 2349 | if (face >= 0 && face < nsides) | |
2107 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
2108 | { | 2350 | { |
2109 | texcolor = tex.GetFace((uint)face).RGBA; | 2351 | texcolor = tex.GetFace((uint)face).RGBA; |
2110 | rgb.x = texcolor.R; | 2352 | rgb.x = texcolor.R; |
@@ -2131,15 +2373,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2131 | m_host.AddScriptLPS(1); | 2373 | m_host.AddScriptLPS(1); |
2132 | 2374 | ||
2133 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 2375 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
2376 | <<<<<<< HEAD | ||
2134 | 2377 | ||
2135 | foreach (SceneObjectPart part in parts) | 2378 | foreach (SceneObjectPart part in parts) |
2136 | SetTexture(part, texture, face); | 2379 | SetTexture(part, texture, face); |
2137 | 2380 | ||
2138 | ScriptSleep(m_sleepMsOnSetLinkTexture); | 2381 | ScriptSleep(m_sleepMsOnSetLinkTexture); |
2382 | ======= | ||
2383 | if (parts.Count > 0) | ||
2384 | { | ||
2385 | try | ||
2386 | { | ||
2387 | foreach (SceneObjectPart part in parts) | ||
2388 | SetTexture(part, texture, face); | ||
2389 | } | ||
2390 | finally | ||
2391 | { | ||
2392 | } | ||
2393 | } | ||
2394 | ScriptSleep(200); | ||
2395 | >>>>>>> avn/ubitvar | ||
2139 | } | 2396 | } |
2140 | 2397 | ||
2141 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 2398 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
2142 | { | 2399 | { |
2400 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2401 | return; | ||
2402 | |||
2143 | UUID textureID = new UUID(); | 2403 | UUID textureID = new UUID(); |
2144 | 2404 | ||
2145 | textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); | 2405 | textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); |
@@ -2184,6 +2444,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2184 | 2444 | ||
2185 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 2445 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
2186 | { | 2446 | { |
2447 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2448 | return; | ||
2449 | |||
2187 | Primitive.TextureEntry tex = part.Shape.Textures; | 2450 | Primitive.TextureEntry tex = part.Shape.Textures; |
2188 | if (face >= 0 && face < GetNumberOfSides(part)) | 2451 | if (face >= 0 && face < GetNumberOfSides(part)) |
2189 | { | 2452 | { |
@@ -2220,6 +2483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2220 | 2483 | ||
2221 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 2484 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
2222 | { | 2485 | { |
2486 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2487 | return; | ||
2488 | |||
2223 | Primitive.TextureEntry tex = part.Shape.Textures; | 2489 | Primitive.TextureEntry tex = part.Shape.Textures; |
2224 | if (face >= 0 && face < GetNumberOfSides(part)) | 2490 | if (face >= 0 && face < GetNumberOfSides(part)) |
2225 | { | 2491 | { |
@@ -2256,6 +2522,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2256 | 2522 | ||
2257 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 2523 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
2258 | { | 2524 | { |
2525 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2526 | return; | ||
2527 | |||
2259 | Primitive.TextureEntry tex = part.Shape.Textures; | 2528 | Primitive.TextureEntry tex = part.Shape.Textures; |
2260 | if (face >= 0 && face < GetNumberOfSides(part)) | 2529 | if (face >= 0 && face < GetNumberOfSides(part)) |
2261 | { | 2530 | { |
@@ -2397,7 +2666,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2397 | return end; | 2666 | return end; |
2398 | } | 2667 | } |
2399 | 2668 | ||
2400 | protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos) | 2669 | protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos, bool adjust) |
2401 | { | 2670 | { |
2402 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 2671 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2403 | return fromPos; | 2672 | return fromPos; |
@@ -2413,9 +2682,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2413 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | 2682 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) |
2414 | targetPos.z = ground; | 2683 | targetPos.z = ground; |
2415 | } | 2684 | } |
2416 | LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); | 2685 | if (adjust) |
2686 | return SetPosAdjust(fromPos, targetPos); | ||
2417 | 2687 | ||
2418 | return real_vec; | 2688 | return targetPos; |
2419 | } | 2689 | } |
2420 | 2690 | ||
2421 | /// <summary> | 2691 | /// <summary> |
@@ -2426,27 +2696,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2426 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> | 2696 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> |
2427 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) | 2697 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) |
2428 | { | 2698 | { |
2429 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2699 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2700 | return; | ||
2701 | |||
2430 | LSL_Vector currentPos = GetPartLocalPos(part); | 2702 | LSL_Vector currentPos = GetPartLocalPos(part); |
2703 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); | ||
2431 | 2704 | ||
2432 | float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); | ||
2433 | bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); | ||
2434 | 2705 | ||
2435 | if (part.ParentGroup.RootPart == part) | 2706 | if (part.ParentGroup.RootPart == part) |
2436 | { | 2707 | { |
2437 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | ||
2438 | targetPos.z = ground; | ||
2439 | SceneObjectGroup parent = part.ParentGroup; | 2708 | SceneObjectGroup parent = part.ParentGroup; |
2440 | parent.UpdateGroupPosition(!adjust ? targetPos : | 2709 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) |
2441 | SetPosAdjust(currentPos, targetPos)); | 2710 | return; |
2711 | Util.FireAndForget(delegate(object x) { | ||
2712 | parent.UpdateGroupPosition((Vector3)toPos); | ||
2713 | }); | ||
2442 | } | 2714 | } |
2443 | else | 2715 | else |
2444 | { | 2716 | { |
2445 | part.OffsetPosition = !adjust ? targetPos : | 2717 | part.OffsetPosition = (Vector3)toPos; |
2446 | SetPosAdjust(currentPos, targetPos); | 2718 | // SceneObjectGroup parent = part.ParentGroup; |
2447 | SceneObjectGroup parent = part.ParentGroup; | 2719 | // parent.HasGroupChanged = true; |
2448 | parent.HasGroupChanged = true; | 2720 | // parent.ScheduleGroupForTerseUpdate(); |
2449 | parent.ScheduleGroupForTerseUpdate(); | 2721 | part.ScheduleTerseUpdate(); |
2450 | } | 2722 | } |
2451 | } | 2723 | } |
2452 | 2724 | ||
@@ -2475,13 +2747,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2475 | else | 2747 | else |
2476 | { | 2748 | { |
2477 | if (part.ParentGroup.IsAttachment) | 2749 | if (part.ParentGroup.IsAttachment) |
2478 | { | ||
2479 | pos = part.AttachedPos; | 2750 | pos = part.AttachedPos; |
2480 | } | ||
2481 | else | 2751 | else |
2482 | { | ||
2483 | pos = part.AbsolutePosition; | 2752 | pos = part.AbsolutePosition; |
2484 | } | ||
2485 | } | 2753 | } |
2486 | 2754 | ||
2487 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); | 2755 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); |
@@ -2493,8 +2761,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2493 | { | 2761 | { |
2494 | m_host.AddScriptLPS(1); | 2762 | m_host.AddScriptLPS(1); |
2495 | 2763 | ||
2764 | |||
2765 | // Teravus: if (m_host.ParentID == 0) is bug code because the ParentID for the Avatar will cause this to be nonzero for root prim attachments | ||
2766 | // which is then treated like a child prim rotation and it's offset gets cumulatively multiplied against. | ||
2767 | // to fix the scripted rotations we also have to check to see if the root part localid is the same as the host's localid. | ||
2768 | // RootPart != null should shortcircuit | ||
2769 | |||
2496 | // try to let this work as in SL... | 2770 | // try to let this work as in SL... |
2497 | if (m_host.ParentID == 0) | 2771 | if (m_host.ParentID == 0 || (m_host.ParentGroup != null && m_host == m_host.ParentGroup.RootPart)) |
2498 | { | 2772 | { |
2499 | // special case: If we are root, rotate complete SOG to new rotation | 2773 | // special case: If we are root, rotate complete SOG to new rotation |
2500 | SetRot(m_host, rot); | 2774 | SetRot(m_host, rot); |
@@ -2521,25 +2795,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2521 | 2795 | ||
2522 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2796 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2523 | { | 2797 | { |
2524 | part.UpdateRotation(rot); | 2798 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2525 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2799 | return; |
2526 | 2800 | ||
2527 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type | 2801 | bool isroot = (part == part.ParentGroup.RootPart); |
2528 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | 2802 | bool isphys; |
2529 | 2803 | ||
2530 | // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line | ||
2531 | // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt | ||
2532 | // It's perfectly okay when the object is not an active physical body though. | ||
2533 | // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against | ||
2534 | // but only if the object is not physial and active. This is important for rotating doors. | ||
2535 | // without the absoluteposition = absoluteposition happening, the doors do not move in the physics | ||
2536 | // scene | ||
2537 | PhysicsActor pa = part.PhysActor; | 2804 | PhysicsActor pa = part.PhysActor; |
2538 | 2805 | ||
2539 | if (pa != null && !pa.IsPhysical) | 2806 | // keep using physactor ideia of isphysical |
2807 | // it should be SOP ideia of that | ||
2808 | // not much of a issue with ubitODE | ||
2809 | if (pa != null && pa.IsPhysical) | ||
2810 | isphys = true; | ||
2811 | else | ||
2812 | isphys = false; | ||
2813 | |||
2814 | // SL doesn't let scripts rotate root of physical linksets | ||
2815 | if (isroot && isphys) | ||
2816 | return; | ||
2817 | |||
2818 | part.UpdateRotation(rot); | ||
2819 | |||
2820 | // Update rotation does not move the object in the physics engine if it's a non physical linkset | ||
2821 | // so do a nasty update of parts positions if is a root part rotation | ||
2822 | if (isroot && pa != null) // with if above implies non physical root part | ||
2540 | { | 2823 | { |
2541 | part.ParentGroup.ResetChildPrimPhysicsPositions(); | 2824 | part.ParentGroup.ResetChildPrimPhysicsPositions(); |
2542 | } | 2825 | } |
2826 | else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part | ||
2827 | { | ||
2828 | List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars(); | ||
2829 | if (sittingavas.Count > 0) | ||
2830 | { | ||
2831 | foreach (ScenePresence av in sittingavas) | ||
2832 | { | ||
2833 | if (isroot || part.LocalId == av.ParentID) | ||
2834 | av.SendTerseUpdateToAllClients(); | ||
2835 | } | ||
2836 | } | ||
2837 | } | ||
2543 | } | 2838 | } |
2544 | 2839 | ||
2545 | /// <summary> | 2840 | /// <summary> |
@@ -2556,6 +2851,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2556 | 2851 | ||
2557 | m_host.AddScriptLPS(1); | 2852 | m_host.AddScriptLPS(1); |
2558 | Quaternion q = m_host.GetWorldRotation(); | 2853 | Quaternion q = m_host.GetWorldRotation(); |
2854 | |||
2855 | if (m_host.ParentGroup != null && m_host.ParentGroup.AttachmentPoint != 0) | ||
2856 | { | ||
2857 | ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | ||
2858 | if (avatar != null) | ||
2859 | { | ||
2860 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | ||
2861 | q = avatar.CameraRotation * q; // Mouselook | ||
2862 | else | ||
2863 | q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate | ||
2864 | } | ||
2865 | } | ||
2866 | |||
2559 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 2867 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
2560 | } | 2868 | } |
2561 | 2869 | ||
@@ -2583,14 +2891,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2583 | return new LSL_Rotation(q); | 2891 | return new LSL_Rotation(q); |
2584 | } | 2892 | } |
2585 | 2893 | ||
2586 | return new LSL_Rotation(part.GetWorldRotation()); | 2894 | q = part.GetWorldRotation(); |
2895 | if (part.ParentGroup.AttachmentPoint != 0) | ||
2896 | { | ||
2897 | ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); | ||
2898 | if (avatar != null) | ||
2899 | { | ||
2900 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | ||
2901 | q = avatar.CameraRotation * q; // Mouselook | ||
2902 | else | ||
2903 | q = avatar.Rotation * q; // Currently infrequently updated so may be inaccurate | ||
2904 | } | ||
2905 | } | ||
2906 | |||
2907 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | ||
2587 | } | 2908 | } |
2588 | 2909 | ||
2589 | public LSL_Rotation llGetLocalRot() | 2910 | public LSL_Rotation llGetLocalRot() |
2590 | { | 2911 | { |
2591 | m_host.AddScriptLPS(1); | 2912 | return GetPartLocalRot(m_host); |
2913 | } | ||
2592 | 2914 | ||
2593 | return new LSL_Rotation(m_host.RotationOffset); | 2915 | private LSL_Rotation GetPartLocalRot(SceneObjectPart part) |
2916 | { | ||
2917 | m_host.AddScriptLPS(1); | ||
2918 | Quaternion rot = part.RotationOffset; | ||
2919 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2594 | } | 2920 | } |
2595 | 2921 | ||
2596 | public void llSetForce(LSL_Vector force, int local) | 2922 | public void llSetForce(LSL_Vector force, int local) |
@@ -2620,32 +2946,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2620 | return force; | 2946 | return force; |
2621 | } | 2947 | } |
2622 | 2948 | ||
2623 | public void llSetVelocity(LSL_Vector velocity, int local) | ||
2624 | { | ||
2625 | m_host.AddScriptLPS(1); | ||
2626 | |||
2627 | if (!m_host.ParentGroup.IsDeleted) | ||
2628 | { | ||
2629 | if (local != 0) | ||
2630 | velocity *= llGetRot(); | ||
2631 | |||
2632 | m_host.ParentGroup.RootPart.Velocity = velocity; | ||
2633 | } | ||
2634 | } | ||
2635 | |||
2636 | public void llSetAngularVelocity(LSL_Vector angularVelocity, int local) | ||
2637 | { | ||
2638 | m_host.AddScriptLPS(1); | ||
2639 | |||
2640 | if (!m_host.ParentGroup.IsDeleted) | ||
2641 | { | ||
2642 | if (local != 0) | ||
2643 | angularVelocity *= llGetRot(); | ||
2644 | |||
2645 | m_host.ParentGroup.RootPart.AngularVelocity = angularVelocity; | ||
2646 | } | ||
2647 | } | ||
2648 | |||
2649 | public LSL_Integer llTarget(LSL_Vector position, double range) | 2949 | public LSL_Integer llTarget(LSL_Vector position, double range) |
2650 | { | 2950 | { |
2651 | m_host.AddScriptLPS(1); | 2951 | m_host.AddScriptLPS(1); |
@@ -2696,16 +2996,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2696 | m_host.ApplyImpulse(v, local != 0); | 2996 | m_host.ApplyImpulse(v, local != 0); |
2697 | } | 2997 | } |
2698 | 2998 | ||
2999 | |||
2699 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 3000 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
2700 | { | 3001 | { |
2701 | m_host.AddScriptLPS(1); | 3002 | m_host.AddScriptLPS(1); |
2702 | m_host.ApplyAngularImpulse(force, local != 0); | 3003 | m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0); |
2703 | } | 3004 | } |
2704 | 3005 | ||
2705 | public void llSetTorque(LSL_Vector torque, int local) | 3006 | public void llSetTorque(LSL_Vector torque, int local) |
2706 | { | 3007 | { |
2707 | m_host.AddScriptLPS(1); | 3008 | m_host.AddScriptLPS(1); |
2708 | m_host.SetAngularImpulse(torque, local != 0); | 3009 | m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0); |
2709 | } | 3010 | } |
2710 | 3011 | ||
2711 | public LSL_Vector llGetTorque() | 3012 | public LSL_Vector llGetTorque() |
@@ -2722,20 +3023,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2722 | llSetTorque(torque, local); | 3023 | llSetTorque(torque, local); |
2723 | } | 3024 | } |
2724 | 3025 | ||
3026 | public void llSetVelocity(LSL_Vector vel, int local) | ||
3027 | { | ||
3028 | m_host.AddScriptLPS(1); | ||
3029 | m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); | ||
3030 | } | ||
3031 | |||
2725 | public LSL_Vector llGetVel() | 3032 | public LSL_Vector llGetVel() |
2726 | { | 3033 | { |
2727 | m_host.AddScriptLPS(1); | 3034 | m_host.AddScriptLPS(1); |
2728 | 3035 | ||
2729 | Vector3 vel; | 3036 | Vector3 vel = Vector3.Zero; |
2730 | 3037 | ||
2731 | if (m_host.ParentGroup.IsAttachment) | 3038 | if (m_host.ParentGroup.IsAttachment) |
2732 | { | 3039 | { |
2733 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | 3040 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); |
3041 | <<<<<<< HEAD | ||
2734 | vel = avatar.GetWorldVelocity(); | 3042 | vel = avatar.GetWorldVelocity(); |
3043 | ======= | ||
3044 | if (avatar != null) | ||
3045 | vel = avatar.Velocity; | ||
3046 | >>>>>>> avn/ubitvar | ||
2735 | } | 3047 | } |
2736 | else | 3048 | else |
2737 | { | 3049 | { |
2738 | vel = m_host.Velocity; | 3050 | vel = m_host.ParentGroup.RootPart.Velocity; |
2739 | } | 3051 | } |
2740 | 3052 | ||
2741 | return new LSL_Vector(vel); | 3053 | return new LSL_Vector(vel); |
@@ -2748,11 +3060,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2748 | return new LSL_Vector(m_host.Acceleration); | 3060 | return new LSL_Vector(m_host.Acceleration); |
2749 | } | 3061 | } |
2750 | 3062 | ||
2751 | public LSL_Vector llGetOmega() | 3063 | public void llSetAngularVelocity(LSL_Vector avel, int local) |
2752 | { | 3064 | { |
2753 | m_host.AddScriptLPS(1); | 3065 | m_host.AddScriptLPS(1); |
3066 | m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); | ||
3067 | } | ||
2754 | 3068 | ||
2755 | return new LSL_Vector(m_host.AngularVelocity); | 3069 | public LSL_Vector llGetOmega() |
3070 | { | ||
3071 | m_host.AddScriptLPS(1); | ||
3072 | Vector3 avel = m_host.AngularVelocity; | ||
3073 | return new LSL_Vector(avel.X, avel.Y, avel.Z); | ||
2756 | } | 3074 | } |
2757 | 3075 | ||
2758 | public LSL_Float llGetTimeOfDay() | 3076 | public LSL_Float llGetTimeOfDay() |
@@ -2806,7 +3124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2806 | m_SoundModule.SendSound( | 3124 | m_SoundModule.SendSound( |
2807 | m_host.UUID, | 3125 | m_host.UUID, |
2808 | ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), | 3126 | ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), |
2809 | volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None, | 3127 | volume, false, 0, |
2810 | 0, false, false); | 3128 | 0, false, false); |
2811 | } | 3129 | } |
2812 | } | 3130 | } |
@@ -2817,7 +3135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2817 | if (m_SoundModule != null) | 3135 | if (m_SoundModule != null) |
2818 | { | 3136 | { |
2819 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), | 3137 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), |
2820 | volume, 20, false); | 3138 | volume, 20, false,false); |
2821 | } | 3139 | } |
2822 | } | 3140 | } |
2823 | 3141 | ||
@@ -2827,16 +3145,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2827 | if (m_SoundModule != null) | 3145 | if (m_SoundModule != null) |
2828 | { | 3146 | { |
2829 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), | 3147 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), |
2830 | volume, 20, true); | 3148 | volume, 20, true, false); |
2831 | } | 3149 | } |
2832 | } | 3150 | } |
2833 | 3151 | ||
2834 | public void llLoopSoundSlave(string sound, double volume) | 3152 | public void llLoopSoundSlave(string sound, double volume) |
2835 | { | 3153 | { |
2836 | m_host.AddScriptLPS(1); | 3154 | m_host.AddScriptLPS(1); |
2837 | lock (m_host.ParentGroup.LoopSoundSlavePrims) | 3155 | if (m_SoundModule != null) |
2838 | { | 3156 | { |
2839 | m_host.ParentGroup.LoopSoundSlavePrims.Add(m_host); | 3157 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), |
3158 | volume, 20, false, true); | ||
2840 | } | 3159 | } |
2841 | } | 3160 | } |
2842 | 3161 | ||
@@ -3111,7 +3430,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3111 | return src.ToLower(); | 3430 | return src.ToLower(); |
3112 | } | 3431 | } |
3113 | 3432 | ||
3114 | public void llGiveMoney(string destination, int amount) | 3433 | public LSL_Integer llGiveMoney(string destination, int amount) |
3115 | { | 3434 | { |
3116 | Util.FireAndForget(x => | 3435 | Util.FireAndForget(x => |
3117 | { | 3436 | { |
@@ -3142,9 +3461,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3142 | return; | 3461 | return; |
3143 | } | 3462 | } |
3144 | 3463 | ||
3464 | string reason; | ||
3145 | money.ObjectGiveMoney( | 3465 | money.ObjectGiveMoney( |
3466 | <<<<<<< HEAD | ||
3146 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | 3467 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); |
3147 | }, null, "LSL_Api.llGiveMoney"); | 3468 | }, null, "LSL_Api.llGiveMoney"); |
3469 | ======= | ||
3470 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero, out reason); | ||
3471 | }); | ||
3472 | |||
3473 | return 0; | ||
3474 | >>>>>>> avn/ubitvar | ||
3148 | } | 3475 | } |
3149 | 3476 | ||
3150 | public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) | 3477 | public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset) |
@@ -3177,6 +3504,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3177 | 3504 | ||
3178 | public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) | 3505 | public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) |
3179 | { | 3506 | { |
3507 | doObjectRez(inventory, pos, vel, rot, param, true); | ||
3508 | } | ||
3509 | |||
3510 | public void doObjectRez(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param, bool atRoot) | ||
3511 | { | ||
3180 | m_host.AddScriptLPS(1); | 3512 | m_host.AddScriptLPS(1); |
3181 | 3513 | ||
3182 | Util.FireAndForget(x => | 3514 | Util.FireAndForget(x => |
@@ -3203,15 +3535,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3203 | return; | 3535 | return; |
3204 | } | 3536 | } |
3205 | 3537 | ||
3206 | // need the magnitude later | 3538 | List<SceneObjectGroup> new_groups = World.RezObject(m_host, item, pos, rot, vel, param, atRoot); |
3207 | // float velmag = (float)Util.GetMagnitude(llvel); | ||
3208 | |||
3209 | List<SceneObjectGroup> new_groups = World.RezObject(m_host, item, pos, rot, vel, param); | ||
3210 | 3539 | ||
3211 | // If either of these are null, then there was an unknown error. | 3540 | // If either of these are null, then there was an unknown error. |
3212 | if (new_groups == null) | 3541 | if (new_groups == null) |
3213 | return; | 3542 | return; |
3214 | 3543 | ||
3544 | bool notAttachment = !m_host.ParentGroup.IsAttachment; | ||
3545 | |||
3215 | foreach (SceneObjectGroup group in new_groups) | 3546 | foreach (SceneObjectGroup group in new_groups) |
3216 | { | 3547 | { |
3217 | // objects rezzed with this method are die_at_edge by default. | 3548 | // objects rezzed with this method are die_at_edge by default. |
@@ -3225,22 +3556,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3225 | group.RootPart.UUID.ToString()) }, | 3556 | group.RootPart.UUID.ToString()) }, |
3226 | new DetectParams[0])); | 3557 | new DetectParams[0])); |
3227 | 3558 | ||
3228 | float groupmass = group.GetMass(); | 3559 | if (notAttachment) |
3560 | { | ||
3561 | float groupmass = group.GetMass(); | ||
3229 | 3562 | ||
3230 | PhysicsActor pa = group.RootPart.PhysActor; | 3563 | PhysicsActor pa = group.RootPart.PhysActor; |
3231 | 3564 | ||
3232 | //Recoil. | 3565 | //Recoil. |
3233 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) | 3566 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) |
3234 | { | ||
3235 | Vector3 recoil = -vel * groupmass * m_recoilScaleFactor; | ||
3236 | if (recoil != Vector3.Zero) | ||
3237 | { | 3567 | { |
3238 | llApplyImpulse(recoil, 0); | 3568 | Vector3 recoil = -vel * groupmass * m_recoilScaleFactor; |
3569 | if (recoil != Vector3.Zero) | ||
3570 | { | ||
3571 | llApplyImpulse(recoil, 0); | ||
3572 | } | ||
3239 | } | 3573 | } |
3240 | } | 3574 | } |
3241 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | 3575 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) |
3242 | } | 3576 | } |
3577 | <<<<<<< HEAD | ||
3243 | }, null, "LSL_Api.llRezAtRoot"); | 3578 | }, null, "LSL_Api.llRezAtRoot"); |
3579 | ======= | ||
3580 | return; | ||
3581 | }); | ||
3582 | >>>>>>> avn/ubitvar | ||
3244 | 3583 | ||
3245 | //ScriptSleep((int)((groupmass * velmag) / 10)); | 3584 | //ScriptSleep((int)((groupmass * velmag) / 10)); |
3246 | ScriptSleep(m_sleepMsOnRezAtRoot); | 3585 | ScriptSleep(m_sleepMsOnRezAtRoot); |
@@ -3248,15 +3587,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3248 | 3587 | ||
3249 | public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) | 3588 | public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) |
3250 | { | 3589 | { |
3251 | llRezAtRoot(inventory, pos, vel, rot, param); | 3590 | doObjectRez(inventory, pos, vel, rot, param, false); |
3252 | } | 3591 | } |
3253 | 3592 | ||
3254 | public void llLookAt(LSL_Vector target, double strength, double damping) | 3593 | public void llLookAt(LSL_Vector target, double strength, double damping) |
3255 | { | 3594 | { |
3256 | m_host.AddScriptLPS(1); | 3595 | m_host.AddScriptLPS(1); |
3257 | // Determine where we are looking from | ||
3258 | LSL_Vector from = llGetPos(); | ||
3259 | 3596 | ||
3597 | <<<<<<< HEAD | ||
3260 | // normalized direction to target | 3598 | // normalized direction to target |
3261 | LSL_Vector dir = llVecNorm(target - from); | 3599 | LSL_Vector dir = llVecNorm(target - from); |
3262 | // use vertical to help compute left axis | 3600 | // use vertical to help compute left axis |
@@ -3274,12 +3612,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3274 | PhysicsActor pa = m_host.PhysActor; | 3612 | PhysicsActor pa = m_host.PhysActor; |
3275 | 3613 | ||
3276 | if (m_host.ParentGroup.IsAttachment || strength == 0 || pa == null || !pa.IsPhysical) | 3614 | if (m_host.ParentGroup.IsAttachment || strength == 0 || pa == null || !pa.IsPhysical) |
3615 | ======= | ||
3616 | // Get the normalized vector to the target | ||
3617 | LSL_Vector d1 = llVecNorm(target - llGetPos()); | ||
3618 | |||
3619 | // Get the bearing (yaw) | ||
3620 | LSL_Vector a1 = new LSL_Vector(0,0,0); | ||
3621 | a1.z = llAtan2(d1.y, d1.x); | ||
3622 | |||
3623 | // Get the elevation (pitch) | ||
3624 | LSL_Vector a2 = new LSL_Vector(0,0,0); | ||
3625 | a2.y= -llAtan2(d1.z, llSqrt((d1.x * d1.x) + (d1.y * d1.y))); | ||
3626 | |||
3627 | LSL_Rotation r1 = llEuler2Rot(a1); | ||
3628 | LSL_Rotation r2 = llEuler2Rot(a2); | ||
3629 | LSL_Rotation r3 = new LSL_Rotation(0.000000, 0.707107, 0.000000, 0.707107); | ||
3630 | |||
3631 | if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) | ||
3632 | >>>>>>> avn/ubitvar | ||
3277 | { | 3633 | { |
3278 | llSetRot(rot); | 3634 | // Do nothing if either value is 0 (this has been checked in SL) |
3635 | if (strength <= 0.0 || damping <= 0.0) | ||
3636 | return; | ||
3637 | |||
3638 | llSetRot(r3 * r2 * r1); | ||
3279 | } | 3639 | } |
3280 | else | 3640 | else |
3281 | { | 3641 | { |
3282 | m_host.StartLookAt(rot, (float)strength, (float)damping); | 3642 | if (strength == 0) |
3643 | { | ||
3644 | llSetRot(r3 * r2 * r1); | ||
3645 | return; | ||
3646 | } | ||
3647 | |||
3648 | m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping); | ||
3283 | } | 3649 | } |
3284 | } | 3650 | } |
3285 | 3651 | ||
@@ -3325,22 +3691,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3325 | } | 3691 | } |
3326 | else | 3692 | else |
3327 | { | 3693 | { |
3328 | if (m_host.IsRoot) | 3694 | // new SL always returns object mass |
3329 | { | 3695 | // if (m_host.IsRoot) |
3696 | // { | ||
3330 | return m_host.ParentGroup.GetMass(); | 3697 | return m_host.ParentGroup.GetMass(); |
3331 | } | 3698 | // } |
3332 | else | 3699 | // else |
3333 | { | 3700 | // { |
3334 | return m_host.GetMass(); | 3701 | // return m_host.GetMass(); |
3335 | } | 3702 | // } |
3336 | } | 3703 | } |
3337 | } | 3704 | } |
3338 | 3705 | ||
3706 | <<<<<<< HEAD | ||
3339 | public LSL_Float llGetMassMKS() | 3707 | public LSL_Float llGetMassMKS() |
3340 | { | 3708 | { |
3341 | // this is what the wiki says it does! | 3709 | // this is what the wiki says it does! |
3342 | // http://wiki.secondlife.com/wiki/LlGetMassMKS | 3710 | // http://wiki.secondlife.com/wiki/LlGetMassMKS |
3343 | return llGetMass() * 100.0; | 3711 | return llGetMass() * 100.0; |
3712 | ======= | ||
3713 | |||
3714 | public LSL_Float llGetMassMKS() | ||
3715 | { | ||
3716 | return 100f * llGetMass(); | ||
3717 | >>>>>>> avn/ubitvar | ||
3344 | } | 3718 | } |
3345 | 3719 | ||
3346 | public void llCollisionFilter(string name, string id, int accept) | 3720 | public void llCollisionFilter(string name, string id, int accept) |
@@ -3390,8 +3764,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3390 | { | 3764 | { |
3391 | // Unregister controls from Presence | 3765 | // Unregister controls from Presence |
3392 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); | 3766 | presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID); |
3393 | // Remove Take Control permission. | ||
3394 | m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; | ||
3395 | } | 3767 | } |
3396 | } | 3768 | } |
3397 | } | 3769 | } |
@@ -3419,7 +3791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3419 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3791 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3420 | 3792 | ||
3421 | if (attachmentsModule != null) | 3793 | if (attachmentsModule != null) |
3422 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, true); | 3794 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false, true); |
3423 | else | 3795 | else |
3424 | return false; | 3796 | return false; |
3425 | } | 3797 | } |
@@ -3449,9 +3821,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3449 | { | 3821 | { |
3450 | m_host.AddScriptLPS(1); | 3822 | m_host.AddScriptLPS(1); |
3451 | 3823 | ||
3452 | // if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
3453 | // return; | ||
3454 | |||
3455 | if (m_item.PermsGranter != m_host.OwnerID) | 3824 | if (m_item.PermsGranter != m_host.OwnerID) |
3456 | return; | 3825 | return; |
3457 | 3826 | ||
@@ -3494,6 +3863,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3494 | 3863 | ||
3495 | public void llInstantMessage(string user, string message) | 3864 | public void llInstantMessage(string user, string message) |
3496 | { | 3865 | { |
3866 | UUID result; | ||
3867 | if (!UUID.TryParse(user, out result) || result == UUID.Zero) | ||
3868 | { | ||
3869 | ShoutError("An invalid key was passed to llInstantMessage"); | ||
3870 | ScriptSleep(2000); | ||
3871 | return; | ||
3872 | } | ||
3873 | |||
3874 | |||
3497 | m_host.AddScriptLPS(1); | 3875 | m_host.AddScriptLPS(1); |
3498 | 3876 | ||
3499 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3877 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -3505,14 +3883,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3505 | 3883 | ||
3506 | // TODO: figure out values for client, fromSession, and imSessionID | 3884 | // TODO: figure out values for client, fromSession, and imSessionID |
3507 | // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); | 3885 | // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); |
3886 | <<<<<<< HEAD | ||
3887 | |||
3888 | ======= | ||
3889 | UUID friendTransactionID = UUID.Random(); | ||
3508 | 3890 | ||
3891 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | ||
3892 | |||
3893 | >>>>>>> avn/ubitvar | ||
3509 | GridInstantMessage msg = new GridInstantMessage(); | 3894 | GridInstantMessage msg = new GridInstantMessage(); |
3510 | msg.fromAgentID = new Guid(m_host.OwnerID.ToString()); // fromAgentID.Guid; | 3895 | msg.fromAgentID = new Guid(m_host.OwnerID.ToString()); // fromAgentID.Guid; |
3511 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3896 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
3512 | msg.imSessionID = new Guid(m_host.UUID.ToString()); // This is the item we're mucking with here | 3897 | msg.imSessionID = new Guid(m_host.UUID.ToString()); // This is the item we're mucking with here |
3513 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | 3898 | // m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); |
3514 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | 3899 | // m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); |
3515 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | 3900 | // DateTime dt = DateTime.UtcNow; |
3901 | // | ||
3902 | // // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
3903 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
3904 | // | ||
3905 | // try | ||
3906 | // { | ||
3907 | // // Convert that to the PST timezone | ||
3908 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
3909 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
3910 | // } | ||
3911 | // catch | ||
3912 | // { | ||
3913 | // // No logging here, as it could be VERY spammy | ||
3914 | // } | ||
3915 | // | ||
3916 | // // And make it look local again to fool the unix time util | ||
3917 | // dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
3918 | |||
3919 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
3920 | |||
3516 | //if (client != null) | 3921 | //if (client != null) |
3517 | //{ | 3922 | //{ |
3518 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | 3923 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; |
@@ -3526,10 +3931,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3526 | msg.message = message.Substring(0, 1024); | 3931 | msg.message = message.Substring(0, 1024); |
3527 | else | 3932 | else |
3528 | msg.message = message; | 3933 | msg.message = message; |
3529 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | 3934 | msg.dialog = (byte)19; // MessageFromObject |
3530 | msg.fromGroup = false;// fromGroup; | 3935 | msg.fromGroup = false;// fromGroup; |
3531 | msg.offline = (byte)0; //offline; | 3936 | msg.offline = (byte)0; //offline; |
3532 | msg.ParentEstateID = 0; //ParentEstateID; | 3937 | msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; |
3533 | msg.Position = new Vector3(m_host.AbsolutePosition); | 3938 | msg.Position = new Vector3(m_host.AbsolutePosition); |
3534 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; | 3939 | msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; |
3535 | 3940 | ||
@@ -3832,7 +4237,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3832 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | 4237 | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | |
3833 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | | 4238 | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | |
3834 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | | 4239 | ScriptBaseClass.PERMISSION_TRACK_CAMERA | |
4240 | <<<<<<< HEAD | ||
3835 | ScriptBaseClass.PERMISSION_ATTACH; | 4241 | ScriptBaseClass.PERMISSION_ATTACH; |
4242 | ======= | ||
4243 | ScriptBaseClass.PERMISSION_ATTACH | | ||
4244 | ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS; | ||
4245 | |||
4246 | >>>>>>> avn/ubitvar | ||
3836 | } | 4247 | } |
3837 | else | 4248 | else |
3838 | { | 4249 | { |
@@ -3849,15 +4260,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3849 | if (World.GetExtraSetting("auto_grant_attach_perms") == "true") | 4260 | if (World.GetExtraSetting("auto_grant_attach_perms") == "true") |
3850 | implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; | 4261 | implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; |
3851 | } | 4262 | } |
4263 | if (World.GetExtraSetting("auto_grant_all_perms") == "true") | ||
4264 | { | ||
4265 | implicitPerms = perm; | ||
4266 | } | ||
3852 | } | 4267 | } |
3853 | 4268 | ||
3854 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 4269 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3855 | { | 4270 | { |
3856 | lock (m_host.TaskInventory) | 4271 | m_host.TaskInventory.LockItemsForWrite(true); |
3857 | { | 4272 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3858 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 4273 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; |
3859 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | 4274 | m_host.TaskInventory.LockItemsForWrite(false); |
3860 | } | ||
3861 | 4275 | ||
3862 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 4276 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( |
3863 | "run_time_permissions", new Object[] { | 4277 | "run_time_permissions", new Object[] { |
@@ -3901,11 +4315,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3901 | 4315 | ||
3902 | if (!m_waitingForScriptAnswer) | 4316 | if (!m_waitingForScriptAnswer) |
3903 | { | 4317 | { |
3904 | lock (m_host.TaskInventory) | 4318 | m_host.TaskInventory.LockItemsForWrite(true); |
3905 | { | 4319 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; |
3906 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | 4320 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; |
3907 | m_host.TaskInventory[m_item.ItemID].PermsMask = 0; | 4321 | m_host.TaskInventory.LockItemsForWrite(false); |
3908 | } | ||
3909 | 4322 | ||
3910 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 4323 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3911 | m_waitingForScriptAnswer=true; | 4324 | m_waitingForScriptAnswer=true; |
@@ -3934,14 +4347,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3934 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 4347 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3935 | llReleaseControls(); | 4348 | llReleaseControls(); |
3936 | 4349 | ||
3937 | lock (m_host.TaskInventory) | 4350 | m_host.TaskInventory.LockItemsForWrite(true); |
3938 | { | 4351 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; |
3939 | m_host.TaskInventory[m_item.ItemID].PermsMask = answer; | 4352 | m_host.TaskInventory.LockItemsForWrite(false); |
3940 | } | 4353 | |
3941 | 4354 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | |
3942 | m_ScriptEngine.PostScriptEvent( | 4355 | "run_time_permissions", new Object[] { |
3943 | m_item.ItemID, | 4356 | new LSL_Integer(answer) }, |
3944 | new EventParams("run_time_permissions", new Object[] { new LSL_Integer(answer) }, new DetectParams[0])); | 4357 | new DetectParams[0])); |
3945 | } | 4358 | } |
3946 | 4359 | ||
3947 | public LSL_String llGetPermissionsKey() | 4360 | public LSL_String llGetPermissionsKey() |
@@ -3980,14 +4393,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3980 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 4393 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3981 | { | 4394 | { |
3982 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 4395 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3983 | 4396 | if (parts.Count > 0) | |
3984 | foreach (SceneObjectPart part in parts) | 4397 | { |
3985 | part.SetFaceColorAlpha(face, color, null); | 4398 | try |
4399 | { | ||
4400 | foreach (SceneObjectPart part in parts) | ||
4401 | part.SetFaceColorAlpha(face, color, null); | ||
4402 | } | ||
4403 | finally | ||
4404 | { | ||
4405 | } | ||
4406 | } | ||
3986 | } | 4407 | } |
3987 | 4408 | ||
3988 | public void llCreateLink(string target, int parent) | 4409 | public void llCreateLink(string target, int parent) |
3989 | { | 4410 | { |
3990 | m_host.AddScriptLPS(1); | 4411 | m_host.AddScriptLPS(1); |
4412 | <<<<<<< HEAD | ||
4413 | ======= | ||
4414 | |||
4415 | UUID targetID; | ||
4416 | |||
4417 | if (!UUID.TryParse(target, out targetID)) | ||
4418 | return; | ||
4419 | >>>>>>> avn/ubitvar | ||
3991 | 4420 | ||
3992 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 4421 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3993 | && !m_automaticLinkPermission) | 4422 | && !m_automaticLinkPermission) |
@@ -4104,10 +4533,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4104 | // Restructuring Multiple Prims. | 4533 | // Restructuring Multiple Prims. |
4105 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 4534 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
4106 | parts.Remove(parentPrim.RootPart); | 4535 | parts.Remove(parentPrim.RootPart); |
4107 | foreach (SceneObjectPart part in parts) | 4536 | if (parts.Count > 0) |
4108 | { | 4537 | { |
4109 | parentPrim.DelinkFromGroup(part.LocalId, true); | 4538 | try |
4539 | { | ||
4540 | foreach (SceneObjectPart part in parts) | ||
4541 | { | ||
4542 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
4543 | } | ||
4544 | } | ||
4545 | finally | ||
4546 | { | ||
4547 | } | ||
4110 | } | 4548 | } |
4549 | |||
4111 | parentPrim.HasGroupChanged = true; | 4550 | parentPrim.HasGroupChanged = true; |
4112 | parentPrim.ScheduleGroupForFullUpdate(); | 4551 | parentPrim.ScheduleGroupForFullUpdate(); |
4113 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 4552 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -4116,12 +4555,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4116 | { | 4555 | { |
4117 | SceneObjectPart newRoot = parts[0]; | 4556 | SceneObjectPart newRoot = parts[0]; |
4118 | parts.Remove(newRoot); | 4557 | parts.Remove(newRoot); |
4119 | foreach (SceneObjectPart part in parts) | 4558 | |
4559 | try | ||
4120 | { | 4560 | { |
4121 | // Required for linking | 4561 | foreach (SceneObjectPart part in parts) |
4122 | part.ClearUpdateSchedule(); | 4562 | { |
4123 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 4563 | part.ClearUpdateSchedule(); |
4564 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
4565 | } | ||
4124 | } | 4566 | } |
4567 | finally | ||
4568 | { | ||
4569 | } | ||
4570 | |||
4571 | |||
4125 | newRoot.ParentGroup.HasGroupChanged = true; | 4572 | newRoot.ParentGroup.HasGroupChanged = true; |
4126 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 4573 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
4127 | } | 4574 | } |
@@ -4142,6 +4589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4142 | { | 4589 | { |
4143 | m_host.AddScriptLPS(1); | 4590 | m_host.AddScriptLPS(1); |
4144 | 4591 | ||
4592 | <<<<<<< HEAD | ||
4145 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 4593 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4146 | && !m_automaticLinkPermission) | 4594 | && !m_automaticLinkPermission) |
4147 | { | 4595 | { |
@@ -4154,6 +4602,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4154 | 4602 | ||
4155 | public void BreakAllLinks() | 4603 | public void BreakAllLinks() |
4156 | { | 4604 | { |
4605 | ======= | ||
4606 | TaskInventoryItem item = m_item; | ||
4607 | |||
4608 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | ||
4609 | && !m_automaticLinkPermission) | ||
4610 | { | ||
4611 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | ||
4612 | return; | ||
4613 | } | ||
4614 | |||
4615 | >>>>>>> avn/ubitvar | ||
4157 | SceneObjectGroup parentPrim = m_host.ParentGroup; | 4616 | SceneObjectGroup parentPrim = m_host.ParentGroup; |
4158 | if (parentPrim.AttachmentPoint != 0) | 4617 | if (parentPrim.AttachmentPoint != 0) |
4159 | return; // Fail silently if attached | 4618 | return; // Fail silently if attached |
@@ -4173,13 +4632,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4173 | public LSL_String llGetLinkKey(int linknum) | 4632 | public LSL_String llGetLinkKey(int linknum) |
4174 | { | 4633 | { |
4175 | m_host.AddScriptLPS(1); | 4634 | m_host.AddScriptLPS(1); |
4635 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | ||
4636 | if (part != null) | ||
4637 | { | ||
4638 | return part.UUID.ToString(); | ||
4639 | } | ||
4640 | else | ||
4641 | { | ||
4642 | if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1)) | ||
4643 | { | ||
4644 | linknum -= (m_host.ParentGroup.PrimCount) + 1; | ||
4176 | 4645 | ||
4646 | <<<<<<< HEAD | ||
4177 | ISceneEntity entity = GetLinkEntity(m_host, linknum); | 4647 | ISceneEntity entity = GetLinkEntity(m_host, linknum); |
4648 | ======= | ||
4649 | if (linknum < 0) | ||
4650 | return UUID.Zero.ToString(); | ||
4651 | >>>>>>> avn/ubitvar | ||
4178 | 4652 | ||
4179 | if (entity != null) | 4653 | List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET); |
4180 | return entity.UUID.ToString(); | 4654 | if (avatars.Count > linknum) |
4181 | else | 4655 | { |
4182 | return ScriptBaseClass.NULL_KEY; | 4656 | return avatars[linknum].UUID.ToString(); |
4657 | } | ||
4658 | } | ||
4659 | return UUID.Zero.ToString(); | ||
4660 | } | ||
4183 | } | 4661 | } |
4184 | 4662 | ||
4185 | /// <summary> | 4663 | /// <summary> |
@@ -4238,17 +4716,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4238 | m_host.AddScriptLPS(1); | 4716 | m_host.AddScriptLPS(1); |
4239 | int count = 0; | 4717 | int count = 0; |
4240 | 4718 | ||
4241 | lock (m_host.TaskInventory) | 4719 | m_host.TaskInventory.LockItemsForRead(true); |
4720 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4242 | { | 4721 | { |
4243 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4722 | if (inv.Value.Type == type || type == -1) |
4244 | { | 4723 | { |
4245 | if (inv.Value.Type == type || type == -1) | 4724 | count = count + 1; |
4246 | { | ||
4247 | count = count + 1; | ||
4248 | } | ||
4249 | } | 4725 | } |
4250 | } | 4726 | } |
4251 | 4727 | ||
4728 | m_host.TaskInventory.LockItemsForRead(false); | ||
4252 | return count; | 4729 | return count; |
4253 | } | 4730 | } |
4254 | 4731 | ||
@@ -4257,16 +4734,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4257 | m_host.AddScriptLPS(1); | 4734 | m_host.AddScriptLPS(1); |
4258 | ArrayList keys = new ArrayList(); | 4735 | ArrayList keys = new ArrayList(); |
4259 | 4736 | ||
4260 | lock (m_host.TaskInventory) | 4737 | m_host.TaskInventory.LockItemsForRead(true); |
4738 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4261 | { | 4739 | { |
4262 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4740 | if (inv.Value.Type == type || type == -1) |
4263 | { | 4741 | { |
4264 | if (inv.Value.Type == type || type == -1) | 4742 | keys.Add(inv.Value.Name); |
4265 | { | ||
4266 | keys.Add(inv.Value.Name); | ||
4267 | } | ||
4268 | } | 4743 | } |
4269 | } | 4744 | } |
4745 | m_host.TaskInventory.LockItemsForRead(false); | ||
4270 | 4746 | ||
4271 | if (keys.Count == 0) | 4747 | if (keys.Count == 0) |
4272 | { | 4748 | { |
@@ -4303,8 +4779,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4303 | 4779 | ||
4304 | if (item == null) | 4780 | if (item == null) |
4305 | { | 4781 | { |
4782 | <<<<<<< HEAD | ||
4306 | Error("llGiveInventory", "Can't find inventory object '" + inventory + "'"); | 4783 | Error("llGiveInventory", "Can't find inventory object '" + inventory + "'"); |
4307 | return; | 4784 | return; |
4785 | ======= | ||
4786 | llSay(0, String.Format("Could not find object '{0}'", inventory)); | ||
4787 | return; | ||
4788 | // throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | ||
4789 | >>>>>>> avn/ubitvar | ||
4308 | } | 4790 | } |
4309 | 4791 | ||
4310 | UUID objId = item.ItemID; | 4792 | UUID objId = item.ItemID; |
@@ -4336,6 +4818,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4336 | } | 4818 | } |
4337 | } | 4819 | } |
4338 | } | 4820 | } |
4821 | |||
4339 | // destination is an avatar | 4822 | // destination is an avatar |
4340 | string message; | 4823 | string message; |
4341 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId, out message); | 4824 | InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId, out message); |
@@ -4346,27 +4829,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4346 | return; | 4829 | return; |
4347 | } | 4830 | } |
4348 | 4831 | ||
4349 | if (m_TransferModule != null) | 4832 | byte[] bucket = new byte[1]; |
4350 | { | 4833 | bucket[0] = (byte)item.Type; |
4351 | byte[] bucket = new byte[1]; | 4834 | //byte[] objBytes = agentItem.ID.GetBytes(); |
4352 | bucket[0] = (byte)item.Type; | 4835 | //Array.Copy(objBytes, 0, bucket, 1, 16); |
4353 | 4836 | ||
4354 | GridInstantMessage msg = new GridInstantMessage(World, | 4837 | GridInstantMessage msg = new GridInstantMessage(World, |
4355 | m_host.OwnerID, m_host.Name, destId, | 4838 | m_host.OwnerID, m_host.Name, destId, |
4356 | (byte)InstantMessageDialog.TaskInventoryOffered, | 4839 | (byte)InstantMessageDialog.TaskInventoryOffered, |
4357 | false, item.Name+". "+m_host.Name+" is located at "+ | 4840 | false, item.Name+". "+m_host.Name+" is located at "+ |
4358 | World.RegionInfo.RegionName+" "+ | 4841 | World.RegionInfo.RegionName+" "+ |
4359 | m_host.AbsolutePosition.ToString(), | 4842 | m_host.AbsolutePosition.ToString(), |
4360 | agentItem.ID, true, m_host.AbsolutePosition, | 4843 | agentItem.ID, true, m_host.AbsolutePosition, |
4361 | bucket, true); | 4844 | bucket, true); |
4362 | 4845 | ||
4363 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4846 | ScenePresence sp; |
4364 | } | ||
4365 | 4847 | ||
4848 | <<<<<<< HEAD | ||
4366 | ScriptSleep(m_sleepMsOnGiveInventory); | 4849 | ScriptSleep(m_sleepMsOnGiveInventory); |
4850 | ======= | ||
4851 | if (World.TryGetScenePresence(destId, out sp)) | ||
4852 | { | ||
4853 | sp.ControllingClient.SendInstantMessage(msg); | ||
4854 | } | ||
4855 | else | ||
4856 | { | ||
4857 | if (m_TransferModule != null) | ||
4858 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | ||
4859 | } | ||
4860 | |||
4861 | //This delay should only occur when giving inventory to avatars. | ||
4862 | ScriptSleep(3000); | ||
4863 | >>>>>>> avn/ubitvar | ||
4367 | } | 4864 | } |
4368 | } | 4865 | } |
4369 | 4866 | ||
4867 | [DebuggerNonUserCode] | ||
4370 | public void llRemoveInventory(string name) | 4868 | public void llRemoveInventory(string name) |
4371 | { | 4869 | { |
4372 | m_host.AddScriptLPS(1); | 4870 | m_host.AddScriptLPS(1); |
@@ -4421,6 +4919,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4421 | { | 4919 | { |
4422 | m_host.AddScriptLPS(1); | 4920 | m_host.AddScriptLPS(1); |
4423 | 4921 | ||
4922 | <<<<<<< HEAD | ||
4424 | UUID uuid = (UUID)id; | 4923 | UUID uuid = (UUID)id; |
4425 | PresenceInfo pinfo = null; | 4924 | PresenceInfo pinfo = null; |
4426 | UserAccount account; | 4925 | UserAccount account; |
@@ -4429,6 +4928,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4429 | 4928 | ||
4430 | lock (m_userInfoCache) | 4929 | lock (m_userInfoCache) |
4431 | { | 4930 | { |
4931 | ======= | ||
4932 | UUID uuid; | ||
4933 | if (UUID.TryParse(id, out uuid)) | ||
4934 | { | ||
4935 | PresenceInfo pinfo = null; | ||
4936 | UserAccount account; | ||
4937 | |||
4938 | UserInfoCacheEntry ce; | ||
4939 | >>>>>>> avn/ubitvar | ||
4432 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) | 4940 | if (!m_userInfoCache.TryGetValue(uuid, out ce)) |
4433 | { | 4941 | { |
4434 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); | 4942 | account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); |
@@ -4437,6 +4945,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4437 | m_userInfoCache[uuid] = null; // Cache negative | 4945 | m_userInfoCache[uuid] = null; // Cache negative |
4438 | return UUID.Zero.ToString(); | 4946 | return UUID.Zero.ToString(); |
4439 | } | 4947 | } |
4948 | <<<<<<< HEAD | ||
4949 | ======= | ||
4950 | |||
4951 | >>>>>>> avn/ubitvar | ||
4440 | 4952 | ||
4441 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | 4953 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
4442 | if (pinfos != null && pinfos.Length > 0) | 4954 | if (pinfos != null && pinfos.Length > 0) |
@@ -4449,6 +4961,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4449 | } | 4961 | } |
4450 | } | 4962 | } |
4451 | } | 4963 | } |
4964 | <<<<<<< HEAD | ||
4452 | 4965 | ||
4453 | ce = new UserInfoCacheEntry(); | 4966 | ce = new UserInfoCacheEntry(); |
4454 | ce.time = Util.EnvironmentTickCount(); | 4967 | ce.time = Util.EnvironmentTickCount(); |
@@ -4481,6 +4994,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4481 | else | 4994 | else |
4482 | { | 4995 | { |
4483 | pinfo = null; | 4996 | pinfo = null; |
4997 | ======= | ||
4998 | |||
4999 | ce = new UserInfoCacheEntry(); | ||
5000 | ce.time = Util.EnvironmentTickCount(); | ||
5001 | ce.account = account; | ||
5002 | ce.pinfo = pinfo; | ||
5003 | m_userInfoCache[uuid] = ce; | ||
5004 | } | ||
5005 | else | ||
5006 | { | ||
5007 | if (ce == null) | ||
5008 | return UUID.Zero.ToString(); | ||
5009 | |||
5010 | account = ce.account; | ||
5011 | pinfo = ce.pinfo; | ||
5012 | } | ||
5013 | |||
5014 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | ||
5015 | { | ||
5016 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); | ||
5017 | if (pinfos != null && pinfos.Length > 0) | ||
5018 | { | ||
5019 | foreach (PresenceInfo p in pinfos) | ||
5020 | { | ||
5021 | if (p.RegionID != UUID.Zero) | ||
5022 | { | ||
5023 | pinfo = p; | ||
5024 | } | ||
5025 | >>>>>>> avn/ubitvar | ||
4484 | } | 5026 | } |
4485 | 5027 | ||
4486 | ce.time = Util.EnvironmentTickCount(); | 5028 | ce.time = Util.EnvironmentTickCount(); |
@@ -4490,11 +5032,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4490 | { | 5032 | { |
4491 | pinfo = ce.pinfo; | 5033 | pinfo = ce.pinfo; |
4492 | } | 5034 | } |
5035 | <<<<<<< HEAD | ||
4493 | } | 5036 | } |
4494 | } | 5037 | } |
5038 | ======= | ||
5039 | else | ||
5040 | pinfo = null; | ||
4495 | 5041 | ||
4496 | string reply = String.Empty; | 5042 | ce.time = Util.EnvironmentTickCount(); |
5043 | ce.pinfo = pinfo; | ||
5044 | } | ||
5045 | >>>>>>> avn/ubitvar | ||
4497 | 5046 | ||
5047 | string reply = String.Empty; | ||
5048 | |||
5049 | <<<<<<< HEAD | ||
4498 | switch (data) | 5050 | switch (data) |
4499 | { | 5051 | { |
4500 | case ScriptBaseClass.DATA_ONLINE: | 5052 | case ScriptBaseClass.DATA_ONLINE: |
@@ -4523,18 +5075,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4523 | default: | 5075 | default: |
4524 | return UUID.Zero.ToString(); // Raise no event | 5076 | return UUID.Zero.ToString(); // Raise no event |
4525 | } | 5077 | } |
5078 | ======= | ||
5079 | switch (data) | ||
5080 | { | ||
5081 | case 1: // DATA_ONLINE (0|1) | ||
5082 | if (pinfo != null && pinfo.RegionID != UUID.Zero) | ||
5083 | reply = "1"; | ||
5084 | else | ||
5085 | reply = "0"; | ||
5086 | break; | ||
5087 | case 2: // DATA_NAME (First Last) | ||
5088 | reply = account.FirstName + " " + account.LastName; | ||
5089 | break; | ||
5090 | case 3: // DATA_BORN (YYYY-MM-DD) | ||
5091 | DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); | ||
5092 | born = born.AddSeconds(account.Created); | ||
5093 | reply = born.ToString("yyyy-MM-dd"); | ||
5094 | break; | ||
5095 | case 4: // DATA_RATING (0,0,0,0,0,0) | ||
5096 | reply = "0,0,0,0,0,0"; | ||
5097 | break; | ||
5098 | case 8: // DATA_PAYINFO (0|1|2|3) | ||
5099 | reply = "0"; | ||
5100 | break; | ||
5101 | default: | ||
5102 | return UUID.Zero.ToString(); // Raise no event | ||
5103 | } | ||
5104 | >>>>>>> avn/ubitvar | ||
4526 | 5105 | ||
4527 | UUID rq = UUID.Random(); | 5106 | UUID rq = UUID.Random(); |
4528 | 5107 | ||
4529 | UUID tid = AsyncCommands. | 5108 | UUID tid = AsyncCommands. |
4530 | DataserverPlugin.RegisterRequest(m_host.LocalId, | 5109 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4531 | m_item.ItemID, rq.ToString()); | 5110 | m_item.ItemID, rq.ToString()); |
4532 | 5111 | ||
4533 | AsyncCommands. | 5112 | AsyncCommands. |
4534 | DataserverPlugin.DataserverReply(rq.ToString(), reply); | 5113 | DataserverPlugin.DataserverReply(rq.ToString(), reply); |
4535 | 5114 | ||
5115 | <<<<<<< HEAD | ||
4536 | ScriptSleep(m_sleepMsOnRequestAgentData); | 5116 | ScriptSleep(m_sleepMsOnRequestAgentData); |
4537 | return tid.ToString(); | 5117 | return tid.ToString(); |
5118 | ======= | ||
5119 | ScriptSleep(100); | ||
5120 | return tid.ToString(); | ||
5121 | } | ||
5122 | else | ||
5123 | { | ||
5124 | ShoutError("Invalid UUID passed to llRequestAgentData."); | ||
5125 | } | ||
5126 | return ""; | ||
5127 | >>>>>>> avn/ubitvar | ||
4538 | } | 5128 | } |
4539 | 5129 | ||
4540 | public LSL_String llRequestInventoryData(string name) | 5130 | public LSL_String llRequestInventoryData(string name) |
@@ -4588,12 +5178,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4588 | if (UUID.TryParse(agent, out agentId)) | 5178 | if (UUID.TryParse(agent, out agentId)) |
4589 | { | 5179 | { |
4590 | ScenePresence presence = World.GetScenePresence(agentId); | 5180 | ScenePresence presence = World.GetScenePresence(agentId); |
4591 | if (presence != null) | 5181 | if (presence != null && presence.PresenceType != PresenceType.Npc) |
4592 | { | 5182 | { |
5183 | // agent must not be a god | ||
5184 | if (presence.UserLevel >= 200) return; | ||
5185 | |||
4593 | // agent must be over the owners land | 5186 | // agent must be over the owners land |
4594 | if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) | 5187 | if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) |
4595 | { | 5188 | { |
4596 | World.TeleportClientHome(agentId, presence.ControllingClient); | 5189 | if (!World.TeleportClientHome(agentId, presence.ControllingClient)) |
5190 | { | ||
5191 | // They can't be teleported home for some reason | ||
5192 | GridRegion regionInfo = World.GridService.GetRegionByUUID(UUID.Zero, new UUID("2b02daac-e298-42fa-9a75-f488d37896e6")); | ||
5193 | if (regionInfo != null) | ||
5194 | { | ||
5195 | World.RequestTeleportLocation( | ||
5196 | presence.ControllingClient, regionInfo.RegionHandle, new Vector3(128, 128, 23), Vector3.Zero, | ||
5197 | (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); | ||
5198 | } | ||
5199 | } | ||
4597 | } | 5200 | } |
4598 | } | 5201 | } |
4599 | } | 5202 | } |
@@ -4611,20 +5214,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4611 | ScenePresence presence = World.GetScenePresence(agentId); | 5214 | ScenePresence presence = World.GetScenePresence(agentId); |
4612 | if (presence != null && presence.PresenceType != PresenceType.Npc) | 5215 | if (presence != null && presence.PresenceType != PresenceType.Npc) |
4613 | { | 5216 | { |
4614 | // agent must not be a god | ||
4615 | if (presence.GodLevel >= 200) return; | ||
4616 | |||
4617 | if (destination == String.Empty) | 5217 | if (destination == String.Empty) |
4618 | destination = World.RegionInfo.RegionName; | 5218 | destination = World.RegionInfo.RegionName; |
4619 | 5219 | ||
4620 | // agent must be over the owners land | 5220 | if (m_item.PermsGranter == agentId) |
4621 | if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) | 5221 | { |
5222 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) | ||
5223 | { | ||
5224 | DoLLTeleport(presence, destination, targetPos, targetLookAt); | ||
5225 | } | ||
5226 | } | ||
5227 | |||
5228 | // agent must be wearing the object | ||
5229 | if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) | ||
4622 | { | 5230 | { |
4623 | DoLLTeleport(presence, destination, targetPos, targetLookAt); | 5231 | DoLLTeleport(presence, destination, targetPos, targetLookAt); |
4624 | } | 5232 | } |
4625 | else // or must be wearing the prim | 5233 | else |
4626 | { | 5234 | { |
4627 | if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) | 5235 | // agent must not be a god |
5236 | if (presence.GodLevel >= 200) return; | ||
5237 | |||
5238 | // agent must be over the owners land | ||
5239 | ILandObject agentLand = World.LandChannel.GetLandObject(presence.AbsolutePosition); | ||
5240 | ILandObject objectLand = World.LandChannel.GetLandObject(m_host.AbsolutePosition); | ||
5241 | if (m_host.OwnerID == objectLand.LandData.OwnerID && m_host.OwnerID == agentLand.LandData.OwnerID) | ||
4628 | { | 5242 | { |
4629 | DoLLTeleport(presence, destination, targetPos, targetLookAt); | 5243 | DoLLTeleport(presence, destination, targetPos, targetLookAt); |
4630 | } | 5244 | } |
@@ -4638,24 +5252,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4638 | m_host.AddScriptLPS(1); | 5252 | m_host.AddScriptLPS(1); |
4639 | UUID agentId = new UUID(); | 5253 | UUID agentId = new UUID(); |
4640 | 5254 | ||
5255 | <<<<<<< HEAD | ||
4641 | ulong regionHandle = Util.RegionWorldLocToHandle((uint)global_coords.x, (uint)global_coords.y); | 5256 | ulong regionHandle = Util.RegionWorldLocToHandle((uint)global_coords.x, (uint)global_coords.y); |
5257 | ======= | ||
5258 | ulong regionHandle = Utils.UIntsToLong((uint)(global_coords.x / 256) * 256, (uint)(global_coords.y / 256) * 256); | ||
5259 | >>>>>>> avn/ubitvar | ||
4642 | 5260 | ||
4643 | if (UUID.TryParse(agent, out agentId)) | 5261 | if (UUID.TryParse(agent, out agentId)) |
4644 | { | 5262 | { |
5263 | // This function is owner only! | ||
5264 | if (m_host.OwnerID != agentId) | ||
5265 | return; | ||
5266 | |||
4645 | ScenePresence presence = World.GetScenePresence(agentId); | 5267 | ScenePresence presence = World.GetScenePresence(agentId); |
5268 | |||
5269 | // Can't TP sitting avatars | ||
5270 | if (presence.ParentID != 0) // Sitting | ||
5271 | return; | ||
5272 | |||
4646 | if (presence != null && presence.PresenceType != PresenceType.Npc) | 5273 | if (presence != null && presence.PresenceType != PresenceType.Npc) |
4647 | { | 5274 | { |
4648 | // agent must not be a god | 5275 | if (m_item.PermsGranter == agentId) |
4649 | if (presence.GodLevel >= 200) return; | ||
4650 | |||
4651 | // agent must be over the owners land | ||
4652 | if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID) | ||
4653 | { | ||
4654 | World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); | ||
4655 | } | ||
4656 | else // or must be wearing the prim | ||
4657 | { | 5276 | { |
4658 | if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.OwnerID == presence.UUID) | 5277 | // If attached using llAttachToAvatarTemp, cowardly refuse |
5278 | if (m_host.ParentGroup.AttachmentPoint != 0 && m_host.ParentGroup.FromItemID == UUID.Zero) | ||
5279 | return; | ||
5280 | |||
5281 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) != 0) | ||
4659 | { | 5282 | { |
4660 | World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); | 5283 | World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); |
4661 | } | 5284 | } |
@@ -4732,9 +5355,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4732 | { | 5355 | { |
4733 | m_host.AddScriptLPS(1); | 5356 | m_host.AddScriptLPS(1); |
4734 | 5357 | ||
5358 | if(impact_sound == "") | ||
5359 | { | ||
5360 | m_host.CollisionSoundVolume = (float)impact_volume; | ||
5361 | m_host.CollisionSound = m_host.invalidCollisionSoundUUID; | ||
5362 | m_host.CollisionSoundType = 0; | ||
5363 | return; | ||
5364 | } | ||
4735 | // TODO: Parameter check logic required. | 5365 | // TODO: Parameter check logic required. |
4736 | m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); | 5366 | m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); |
4737 | m_host.CollisionSoundVolume = (float)impact_volume; | 5367 | m_host.CollisionSoundVolume = (float)impact_volume; |
5368 | m_host.CollisionSoundType = 1; | ||
4738 | } | 5369 | } |
4739 | 5370 | ||
4740 | public LSL_String llGetAnimation(string id) | 5371 | public LSL_String llGetAnimation(string id) |
@@ -4748,14 +5379,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4748 | 5379 | ||
4749 | if (m_host.RegionHandle == presence.RegionHandle) | 5380 | if (m_host.RegionHandle == presence.RegionHandle) |
4750 | { | 5381 | { |
4751 | Dictionary<UUID, string> animationstateNames = DefaultAvatarAnimations.AnimStateNames; | ||
4752 | |||
4753 | if (presence != null) | 5382 | if (presence != null) |
4754 | { | 5383 | { |
4755 | AnimationSet currentAnims = presence.Animator.Animations; | 5384 | // if (presence.SitGround) |
4756 | string currentAnimationState = String.Empty; | 5385 | // return "Sitting on Ground"; |
4757 | if (animationstateNames.TryGetValue(currentAnims.ImplicitDefaultAnimation.AnimID, out currentAnimationState)) | 5386 | // if (presence.ParentID != 0 || presence.ParentUUID != UUID.Zero) |
4758 | return currentAnimationState; | 5387 | // return "Sitting"; |
5388 | |||
5389 | string movementAnimation = presence.Animator.CurrentMovementAnimation; | ||
5390 | string lslMovementAnimation; | ||
5391 | |||
5392 | if (MovementAnimationsForLSL.TryGetValue(movementAnimation, out lslMovementAnimation)) | ||
5393 | return lslMovementAnimation; | ||
4759 | } | 5394 | } |
4760 | } | 5395 | } |
4761 | 5396 | ||
@@ -4903,7 +5538,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4903 | { | 5538 | { |
4904 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); | 5539 | float distance = (PusheePos - m_host.AbsolutePosition).Length(); |
4905 | float distance_term = distance * distance * distance; // Script Energy | 5540 | float distance_term = distance * distance * distance; // Script Energy |
4906 | float pusher_mass = m_host.GetMass(); | 5541 | // use total object mass and not part |
5542 | float pusher_mass = m_host.ParentGroup.GetMass(); | ||
4907 | 5543 | ||
4908 | float PUSH_ATTENUATION_DISTANCE = 17f; | 5544 | float PUSH_ATTENUATION_DISTANCE = 17f; |
4909 | float PUSH_ATTENUATION_SCALE = 5f; | 5545 | float PUSH_ATTENUATION_SCALE = 5f; |
@@ -4938,7 +5574,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4938 | { | 5574 | { |
4939 | if (local != 0) | 5575 | if (local != 0) |
4940 | { | 5576 | { |
4941 | applied_linear_impulse *= m_host.GetWorldRotation(); | 5577 | // applied_linear_impulse *= m_host.GetWorldRotation(); |
5578 | applied_linear_impulse *= pusheeav.GetWorldRotation(); | ||
4942 | } | 5579 | } |
4943 | 5580 | ||
4944 | pa.AddForce(applied_linear_impulse, true); | 5581 | pa.AddForce(applied_linear_impulse, true); |
@@ -5292,14 +5929,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5292 | { | 5929 | { |
5293 | m_host.AddScriptLPS(1); | 5930 | m_host.AddScriptLPS(1); |
5294 | 5931 | ||
5295 | if (src == null) | 5932 | return src.Length; |
5296 | { | ||
5297 | return 0; | ||
5298 | } | ||
5299 | else | ||
5300 | { | ||
5301 | return src.Length; | ||
5302 | } | ||
5303 | } | 5933 | } |
5304 | 5934 | ||
5305 | public LSL_Integer llList2Integer(LSL_List src, int index) | 5935 | public LSL_Integer llList2Integer(LSL_List src, int index) |
@@ -5370,7 +6000,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5370 | else if (src.Data[index] is LSL_Float) | 6000 | else if (src.Data[index] is LSL_Float) |
5371 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); | 6001 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); |
5372 | else if (src.Data[index] is LSL_String) | 6002 | else if (src.Data[index] is LSL_String) |
5373 | return Convert.ToDouble(((LSL_String)src.Data[index]).m_string); | 6003 | { |
6004 | string str = ((LSL_String) src.Data[index]).m_string; | ||
6005 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
6006 | if (m != Match.Empty) | ||
6007 | { | ||
6008 | str = m.Value; | ||
6009 | double d = 0.0; | ||
6010 | if (!Double.TryParse(str, out d)) | ||
6011 | return 0.0; | ||
6012 | |||
6013 | return d; | ||
6014 | } | ||
6015 | return 0.0; | ||
6016 | } | ||
5374 | return Convert.ToDouble(src.Data[index]); | 6017 | return Convert.ToDouble(src.Data[index]); |
5375 | } | 6018 | } |
5376 | catch (FormatException) | 6019 | catch (FormatException) |
@@ -5414,8 +6057,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5414 | // NOTE: 3rd case is needed because a NULL_KEY comes through as | 6057 | // NOTE: 3rd case is needed because a NULL_KEY comes through as |
5415 | // type 'obj' and wrongly returns "" | 6058 | // type 'obj' and wrongly returns "" |
5416 | else if (!(src.Data[index] is LSL_String || | 6059 | else if (!(src.Data[index] is LSL_String || |
6060 | <<<<<<< HEAD | ||
5417 | src.Data[index] is LSL_Key || | 6061 | src.Data[index] is LSL_Key || |
5418 | src.Data[index].ToString() == "00000000-0000-0000-0000-000000000000")) | 6062 | src.Data[index].ToString() == "00000000-0000-0000-0000-000000000000")) |
6063 | ======= | ||
6064 | src.Data[index] is LSL_Key || | ||
6065 | src.Data[index] is String)) | ||
6066 | >>>>>>> avn/ubitvar | ||
5419 | { | 6067 | { |
5420 | return ""; | 6068 | return ""; |
5421 | } | 6069 | } |
@@ -5674,7 +6322,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5674 | } | 6322 | } |
5675 | } | 6323 | } |
5676 | } | 6324 | } |
5677 | else { | 6325 | else |
6326 | { | ||
5678 | object[] array = new object[src.Length]; | 6327 | object[] array = new object[src.Length]; |
5679 | Array.Copy(src.Data, 0, array, 0, src.Length); | 6328 | Array.Copy(src.Data, 0, array, 0, src.Length); |
5680 | result = new LSL_List(array); | 6329 | result = new LSL_List(array); |
@@ -5781,13 +6430,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5781 | public LSL_Integer llGetRegionAgentCount() | 6430 | public LSL_Integer llGetRegionAgentCount() |
5782 | { | 6431 | { |
5783 | m_host.AddScriptLPS(1); | 6432 | m_host.AddScriptLPS(1); |
5784 | return new LSL_Integer(World.GetRootAgentCount()); | 6433 | |
6434 | int count = 0; | ||
6435 | World.ForEachRootScenePresence(delegate(ScenePresence sp) { | ||
6436 | count++; | ||
6437 | }); | ||
6438 | |||
6439 | return new LSL_Integer(count); | ||
5785 | } | 6440 | } |
5786 | 6441 | ||
5787 | public LSL_Vector llGetRegionCorner() | 6442 | public LSL_Vector llGetRegionCorner() |
5788 | { | 6443 | { |
5789 | m_host.AddScriptLPS(1); | 6444 | m_host.AddScriptLPS(1); |
5790 | return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0); | 6445 | return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0); |
6446 | <<<<<<< HEAD | ||
5791 | } | 6447 | } |
5792 | 6448 | ||
5793 | public LSL_String llGetEnv(LSL_String name) | 6449 | public LSL_String llGetEnv(LSL_String name) |
@@ -5853,6 +6509,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5853 | { | 6509 | { |
5854 | return ""; | 6510 | return ""; |
5855 | } | 6511 | } |
6512 | ======= | ||
6513 | >>>>>>> avn/ubitvar | ||
5856 | } | 6514 | } |
5857 | 6515 | ||
5858 | /// <summary> | 6516 | /// <summary> |
@@ -5928,17 +6586,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5928 | { | 6586 | { |
5929 | for (int i = 0; i < length; i++) | 6587 | for (int i = 0; i < length; i++) |
5930 | { | 6588 | { |
6589 | int needle = llGetListEntryType(test, 0).value; | ||
6590 | int haystack = llGetListEntryType(src, i).value; | ||
6591 | |||
5931 | // Why this piece of insanity? This is because most script constants are C# value types (e.g. int) | 6592 | // Why this piece of insanity? This is because most script constants are C# value types (e.g. int) |
5932 | // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code | 6593 | // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code |
5933 | // and so the comparison fails even if the LSL_Integer conceptually has the same value. | 6594 | // and so the comparison fails even if the LSL_Integer conceptually has the same value. |
5934 | // Therefore, here we test Equals on both the source and destination objects. | 6595 | // Therefore, here we test Equals on both the source and destination objects. |
5935 | // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). | 6596 | // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). |
5936 | if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])) | 6597 | if ((needle == haystack) && (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))) |
5937 | { | 6598 | { |
5938 | int j; | 6599 | int j; |
5939 | for (j = 1; j < test.Length; j++) | 6600 | for (j = 1; j < test.Length; j++) |
5940 | if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))) | 6601 | { |
6602 | needle = llGetListEntryType(test, j).value; | ||
6603 | haystack = llGetListEntryType(src, i+j).value; | ||
6604 | |||
6605 | if ((needle != haystack) || (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))) | ||
5941 | break; | 6606 | break; |
6607 | } | ||
5942 | 6608 | ||
5943 | if (j == test.Length) | 6609 | if (j == test.Length) |
5944 | { | 6610 | { |
@@ -6087,6 +6753,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6087 | flags |= ScriptBaseClass.AGENT_AWAY; | 6753 | flags |= ScriptBaseClass.AGENT_AWAY; |
6088 | } | 6754 | } |
6089 | 6755 | ||
6756 | UUID busy = new UUID("efcf670c-2d18-8128-973a-034ebc806b67"); | ||
6757 | UUID[] anims = agent.Animator.GetAnimationArray(); | ||
6758 | if (Array.Exists<UUID>(anims, a => { return a == busy; })) | ||
6759 | { | ||
6760 | flags |= ScriptBaseClass.AGENT_BUSY; | ||
6761 | } | ||
6762 | |||
6090 | // seems to get unset, even if in mouselook, when avatar is sitting on a prim??? | 6763 | // seems to get unset, even if in mouselook, when avatar is sitting on a prim??? |
6091 | if ((agent.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | 6764 | if ((agent.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) |
6092 | { | 6765 | { |
@@ -6134,6 +6807,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6134 | flags |= ScriptBaseClass.AGENT_SITTING; | 6807 | flags |= ScriptBaseClass.AGENT_SITTING; |
6135 | } | 6808 | } |
6136 | 6809 | ||
6810 | if (agent.Appearance.VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MALE] > 0) | ||
6811 | { | ||
6812 | flags |= ScriptBaseClass.AGENT_MALE; | ||
6813 | } | ||
6814 | |||
6137 | return flags; | 6815 | return flags; |
6138 | } | 6816 | } |
6139 | 6817 | ||
@@ -6288,9 +6966,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6288 | 6966 | ||
6289 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6967 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6290 | 6968 | ||
6291 | foreach (SceneObjectPart part in parts) | 6969 | try |
6970 | { | ||
6971 | foreach (SceneObjectPart part in parts) | ||
6972 | { | ||
6973 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6974 | } | ||
6975 | } | ||
6976 | finally | ||
6292 | { | 6977 | { |
6293 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6294 | } | 6978 | } |
6295 | } | 6979 | } |
6296 | 6980 | ||
@@ -6344,13 +7028,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6344 | 7028 | ||
6345 | if (m_host.OwnerID == land.LandData.OwnerID) | 7029 | if (m_host.OwnerID == land.LandData.OwnerID) |
6346 | { | 7030 | { |
6347 | World.TeleportClientHome(agentID, presence.ControllingClient); | 7031 | Vector3 p = World.GetNearestAllowedPosition(presence, land); |
7032 | presence.TeleportWithMomentum(p, null); | ||
7033 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | ||
6348 | } | 7034 | } |
6349 | } | 7035 | } |
6350 | } | 7036 | } |
6351 | ScriptSleep(m_sleepMsOnEjectFromLand); | 7037 | ScriptSleep(m_sleepMsOnEjectFromLand); |
6352 | } | 7038 | } |
6353 | 7039 | ||
7040 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
7041 | { | ||
7042 | return ParseString2List(str, separators, in_spacers, false); | ||
7043 | } | ||
7044 | |||
6354 | public LSL_Integer llOverMyLand(string id) | 7045 | public LSL_Integer llOverMyLand(string id) |
6355 | { | 7046 | { |
6356 | m_host.AddScriptLPS(1); | 7047 | m_host.AddScriptLPS(1); |
@@ -6403,26 +7094,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6403 | } | 7094 | } |
6404 | else | 7095 | else |
6405 | { | 7096 | { |
6406 | agentSize = GetAgentSize(avatar); | 7097 | // agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight); |
7098 | Vector3 s = avatar.Appearance.AvatarSize; | ||
7099 | agentSize = new LSL_Vector(s.X, s.Y, s.Z); | ||
6407 | } | 7100 | } |
6408 | |||
6409 | return agentSize; | 7101 | return agentSize; |
6410 | } | 7102 | } |
6411 | 7103 | ||
6412 | public LSL_Integer llSameGroup(string agent) | 7104 | public LSL_Integer llSameGroup(string id) |
6413 | { | 7105 | { |
6414 | m_host.AddScriptLPS(1); | 7106 | m_host.AddScriptLPS(1); |
6415 | UUID agentId = new UUID(); | 7107 | UUID uuid = new UUID(); |
6416 | if (!UUID.TryParse(agent, out agentId)) | 7108 | if (!UUID.TryParse(id, out uuid)) |
6417 | return new LSL_Integer(0); | ||
6418 | ScenePresence presence = World.GetScenePresence(agentId); | ||
6419 | if (presence == null || presence.IsChildAgent) // Return flase for child agents | ||
6420 | return new LSL_Integer(0); | 7109 | return new LSL_Integer(0); |
6421 | IClientAPI client = presence.ControllingClient; | 7110 | |
6422 | if (m_host.GroupID == client.ActiveGroupId) | 7111 | // Check if it's a group key |
7112 | if (uuid == m_host.ParentGroup.RootPart.GroupID) | ||
6423 | return new LSL_Integer(1); | 7113 | return new LSL_Integer(1); |
6424 | else | 7114 | |
7115 | // We got passed a UUID.Zero | ||
7116 | if (uuid == UUID.Zero) | ||
7117 | return new LSL_Integer(0); | ||
7118 | |||
7119 | // Handle the case where id names an avatar | ||
7120 | ScenePresence presence = World.GetScenePresence(uuid); | ||
7121 | if (presence != null) | ||
7122 | { | ||
7123 | if (presence.IsChildAgent) | ||
7124 | return new LSL_Integer(0); | ||
7125 | |||
7126 | IClientAPI client = presence.ControllingClient; | ||
7127 | if (m_host.ParentGroup.RootPart.GroupID == client.ActiveGroupId) | ||
7128 | return new LSL_Integer(1); | ||
7129 | |||
7130 | return new LSL_Integer(0); | ||
7131 | } | ||
7132 | |||
7133 | // Handle object case | ||
7134 | SceneObjectPart part = World.GetSceneObjectPart(uuid); | ||
7135 | if (part != null) | ||
7136 | { | ||
7137 | // This will handle both deed and non-deed and also the no | ||
7138 | // group case | ||
7139 | if (part.ParentGroup.RootPart.GroupID == m_host.ParentGroup.RootPart.GroupID) | ||
7140 | return new LSL_Integer(1); | ||
7141 | |||
6425 | return new LSL_Integer(0); | 7142 | return new LSL_Integer(0); |
7143 | } | ||
7144 | |||
7145 | return new LSL_Integer(0); | ||
6426 | } | 7146 | } |
6427 | 7147 | ||
6428 | public void llUnSit(string id) | 7148 | public void llUnSit(string id) |
@@ -7236,6 +7956,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7236 | 7956 | ||
7237 | protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) | 7957 | protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) |
7238 | { | 7958 | { |
7959 | // LSL quaternions can normalize to 0, normal Quaternions can't. | ||
7960 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | ||
7961 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 | ||
7962 | |||
7239 | part.SitTargetPosition = offset; | 7963 | part.SitTargetPosition = offset; |
7240 | part.SitTargetOrientation = rot; | 7964 | part.SitTargetOrientation = rot; |
7241 | part.ParentGroup.HasGroupChanged = true; | 7965 | part.ParentGroup.HasGroupChanged = true; |
@@ -7290,7 +8014,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7290 | UUID key; | 8014 | UUID key; |
7291 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); | 8015 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
7292 | 8016 | ||
7293 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) | 8017 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) |
7294 | { | 8018 | { |
7295 | int expires = 0; | 8019 | int expires = 0; |
7296 | if (hours != 0) | 8020 | if (hours != 0) |
@@ -7428,11 +8152,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7428 | UUID av = new UUID(); | 8152 | UUID av = new UUID(); |
7429 | if (!UUID.TryParse(avatar,out av)) | 8153 | if (!UUID.TryParse(avatar,out av)) |
7430 | { | 8154 | { |
8155 | <<<<<<< HEAD | ||
7431 | Error("llDialog", "First parameter must be a key"); | 8156 | Error("llDialog", "First parameter must be a key"); |
8157 | ======= | ||
8158 | //LSLError("First parameter to llDialog needs to be a key"); | ||
8159 | >>>>>>> avn/ubitvar | ||
7432 | return; | 8160 | return; |
7433 | } | 8161 | } |
7434 | if (buttons.Length < 1) | 8162 | if (buttons.Length < 1) |
7435 | { | 8163 | { |
8164 | <<<<<<< HEAD | ||
7436 | Error("llDialog", "At least 1 button must be shown"); | 8165 | Error("llDialog", "At least 1 button must be shown"); |
7437 | return; | 8166 | return; |
7438 | } | 8167 | } |
@@ -7440,18 +8169,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7440 | { | 8169 | { |
7441 | Error("llDialog", "No more than 12 buttons can be shown"); | 8170 | Error("llDialog", "No more than 12 buttons can be shown"); |
7442 | return; | 8171 | return; |
8172 | ======= | ||
8173 | buttons.Add("OK"); | ||
7443 | } | 8174 | } |
7444 | string[] buts = new string[buttons.Length]; | 8175 | if (buttons.Length > 12) |
7445 | for (int i = 0; i < buttons.Length; i++) | 8176 | { |
8177 | ShoutError("button list too long, must be 12 or fewer entries"); | ||
8178 | >>>>>>> avn/ubitvar | ||
8179 | } | ||
8180 | int length = buttons.Length; | ||
8181 | if (length > 12) | ||
8182 | length = 12; | ||
8183 | |||
8184 | string[] buts = new string[length]; | ||
8185 | for (int i = 0; i < length; i++) | ||
7446 | { | 8186 | { |
7447 | if (buttons.Data[i].ToString() == String.Empty) | 8187 | if (buttons.Data[i].ToString() == String.Empty) |
7448 | { | 8188 | { |
8189 | <<<<<<< HEAD | ||
7449 | Error("llDialog", "Button label cannot be blank"); | 8190 | Error("llDialog", "Button label cannot be blank"); |
8191 | ======= | ||
8192 | ShoutError("button label cannot be blank"); | ||
8193 | >>>>>>> avn/ubitvar | ||
7450 | return; | 8194 | return; |
7451 | } | 8195 | } |
7452 | if (buttons.Data[i].ToString().Length > 24) | 8196 | if (buttons.Data[i].ToString().Length > 24) |
7453 | { | 8197 | { |
8198 | <<<<<<< HEAD | ||
7454 | Error("llDialog", "Button label cannot be longer than 24 characters"); | 8199 | Error("llDialog", "Button label cannot be longer than 24 characters"); |
8200 | ======= | ||
8201 | ShoutError("button label cannot be longer than 24 characters"); | ||
8202 | >>>>>>> avn/ubitvar | ||
7455 | return; | 8203 | return; |
7456 | } | 8204 | } |
7457 | buts[i] = buttons.Data[i].ToString(); | 8205 | buts[i] = buttons.Data[i].ToString(); |
@@ -7513,9 +8261,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7513 | return; | 8261 | return; |
7514 | } | 8262 | } |
7515 | 8263 | ||
7516 | // the rest of the permission checks are done in RezScript, so check the pin there as well | 8264 | SceneObjectPart dest = World.GetSceneObjectPart(destId); |
7517 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); | 8265 | if (dest != null) |
8266 | { | ||
8267 | if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) | ||
8268 | { | ||
8269 | // the rest of the permission checks are done in RezScript, so check the pin there as well | ||
8270 | World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param); | ||
7518 | 8271 | ||
8272 | if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0) | ||
8273 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | ||
8274 | } | ||
8275 | } | ||
7519 | // this will cause the delay even if the script pin or permissions were wrong - seems ok | 8276 | // this will cause the delay even if the script pin or permissions were wrong - seems ok |
7520 | ScriptSleep(m_sleepMsOnRemoteLoadScriptPin); | 8277 | ScriptSleep(m_sleepMsOnRemoteLoadScriptPin); |
7521 | } | 8278 | } |
@@ -7589,19 +8346,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7589 | public LSL_String llMD5String(string src, int nonce) | 8346 | public LSL_String llMD5String(string src, int nonce) |
7590 | { | 8347 | { |
7591 | m_host.AddScriptLPS(1); | 8348 | m_host.AddScriptLPS(1); |
7592 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString())); | 8349 | return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8); |
7593 | } | 8350 | } |
7594 | 8351 | ||
7595 | public LSL_String llSHA1String(string src) | 8352 | public LSL_String llSHA1String(string src) |
7596 | { | 8353 | { |
7597 | m_host.AddScriptLPS(1); | 8354 | m_host.AddScriptLPS(1); |
7598 | return Util.SHA1Hash(src).ToLower(); | 8355 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
7599 | } | 8356 | } |
7600 | 8357 | ||
7601 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) | 8358 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) |
7602 | { | 8359 | { |
7603 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 8360 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
7604 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 8361 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
8362 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8363 | return shapeBlock; | ||
7605 | 8364 | ||
7606 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 8365 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
7607 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 8366 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -7706,6 +8465,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7706 | // Prim type box, cylinder and prism. | 8465 | // Prim type box, cylinder and prism. |
7707 | 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) | 8466 | 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) |
7708 | { | 8467 | { |
8468 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8469 | return; | ||
8470 | |||
7709 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 8471 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
7710 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 8472 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7711 | 8473 | ||
@@ -7759,6 +8521,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7759 | // Prim type sphere. | 8521 | // Prim type sphere. |
7760 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) | 8522 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) |
7761 | { | 8523 | { |
8524 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8525 | return; | ||
8526 | |||
7762 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 8527 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7763 | 8528 | ||
7764 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); | 8529 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
@@ -7805,6 +8570,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7805 | // Prim type torus, tube and ring. | 8570 | // Prim type torus, tube and ring. |
7806 | 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) | 8571 | 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) |
7807 | { | 8572 | { |
8573 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8574 | return; | ||
8575 | |||
7808 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. | 8576 | float tempFloat; // Use in float expressions below to avoid byte cast precision issues. |
7809 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 8577 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7810 | 8578 | ||
@@ -7940,6 +8708,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7940 | // Prim type sculpt. | 8708 | // Prim type sculpt. |
7941 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) | 8709 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) |
7942 | { | 8710 | { |
8711 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8712 | return; | ||
8713 | |||
7943 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 8714 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7944 | UUID sculptId; | 8715 | UUID sculptId; |
7945 | 8716 | ||
@@ -7962,7 +8733,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7962 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) | 8733 | type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) |
7963 | { | 8734 | { |
7964 | // default | 8735 | // default |
7965 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 8736 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
7966 | } | 8737 | } |
7967 | 8738 | ||
7968 | part.Shape.SetSculptProperties((byte)type, sculptId); | 8739 | part.Shape.SetSculptProperties((byte)type, sculptId); |
@@ -7979,6 +8750,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7979 | ScriptSleep(m_sleepMsOnSetPrimitiveParams); | 8750 | ScriptSleep(m_sleepMsOnSetPrimitiveParams); |
7980 | } | 8751 | } |
7981 | 8752 | ||
8753 | <<<<<<< HEAD | ||
7982 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 8754 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
7983 | { | 8755 | { |
7984 | m_host.AddScriptLPS(1); | 8756 | m_host.AddScriptLPS(1); |
@@ -7988,6 +8760,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7988 | ScriptSleep(m_sleepMsOnSetLinkPrimitiveParams); | 8760 | ScriptSleep(m_sleepMsOnSetLinkPrimitiveParams); |
7989 | } | 8761 | } |
7990 | 8762 | ||
8763 | ======= | ||
8764 | >>>>>>> avn/ubitvar | ||
7991 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 8765 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
7992 | { | 8766 | { |
7993 | m_host.AddScriptLPS(1); | 8767 | m_host.AddScriptLPS(1); |
@@ -7995,16 +8769,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7995 | SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); | 8769 | SetLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); |
7996 | } | 8770 | } |
7997 | 8771 | ||
8772 | <<<<<<< HEAD | ||
7998 | protected void SetLinkPrimParams(int linknumber, LSL_List rules, string originFunc) | 8773 | protected void SetLinkPrimParams(int linknumber, LSL_List rules, string originFunc) |
7999 | { | 8774 | { |
8000 | SetEntityParams(GetLinkEntities(linknumber), rules, originFunc); | 8775 | SetEntityParams(GetLinkEntities(linknumber), rules, originFunc); |
8001 | } | 8776 | } |
8777 | ======= | ||
8778 | private void setLinkPrimParams(int linknumber, LSL_List rules, string originFunc) | ||
8779 | { | ||
8780 | List<object> parts = new List<object>(); | ||
8781 | List<SceneObjectPart> prims = GetLinkParts(linknumber); | ||
8782 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | ||
8783 | foreach (SceneObjectPart p in prims) | ||
8784 | parts.Add(p); | ||
8785 | foreach (ScenePresence p in avatars) | ||
8786 | parts.Add(p); | ||
8787 | >>>>>>> avn/ubitvar | ||
8002 | 8788 | ||
8003 | protected void SetEntityParams(List<ISceneEntity> entities, LSL_List rules, string originFunc) | 8789 | protected void SetEntityParams(List<ISceneEntity> entities, LSL_List rules, string originFunc) |
8004 | { | 8790 | { |
8005 | LSL_List remaining = new LSL_List(); | 8791 | LSL_List remaining = new LSL_List(); |
8006 | uint rulesParsed = 0; | 8792 | uint rulesParsed = 0; |
8007 | 8793 | ||
8794 | <<<<<<< HEAD | ||
8008 | foreach (ISceneEntity entity in entities) | 8795 | foreach (ISceneEntity entity in entities) |
8009 | { | 8796 | { |
8010 | if (entity is SceneObjectPart) | 8797 | if (entity is SceneObjectPart) |
@@ -8049,138 +8836,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8049 | return; | 8836 | return; |
8050 | 8837 | ||
8051 | if (frames.Data.Length > 0) // We are getting a new motion | 8838 | if (frames.Data.Length > 0) // We are getting a new motion |
8839 | ======= | ||
8840 | if (parts.Count > 0) | ||
8841 | >>>>>>> avn/ubitvar | ||
8052 | { | 8842 | { |
8053 | if (group.RootPart.KeyframeMotion != null) | 8843 | foreach (object part in parts) |
8054 | group.RootPart.KeyframeMotion.Delete(); | ||
8055 | group.RootPart.KeyframeMotion = null; | ||
8056 | |||
8057 | int idx = 0; | ||
8058 | |||
8059 | KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; | ||
8060 | KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; | ||
8061 | |||
8062 | while (idx < options.Data.Length) | ||
8063 | { | 8844 | { |
8064 | int option = (int)options.GetLSLIntegerItem(idx++); | 8845 | if (part is SceneObjectPart) |
8065 | int remain = options.Data.Length - idx; | 8846 | remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); |
8847 | else | ||
8848 | remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); | ||
8849 | } | ||
8066 | 8850 | ||
8067 | switch (option) | 8851 | while ((object)remaining != null && remaining.Length > 2) |
8852 | { | ||
8853 | linknumber = remaining.GetLSLIntegerItem(0); | ||
8854 | rules = remaining.GetSublist(1, -1); | ||
8855 | parts.Clear(); | ||
8856 | prims = GetLinkParts(linknumber); | ||
8857 | avatars = GetLinkAvatars(linknumber); | ||
8858 | foreach (SceneObjectPart p in prims) | ||
8859 | parts.Add(p); | ||
8860 | foreach (ScenePresence p in avatars) | ||
8861 | parts.Add(p); | ||
8862 | |||
8863 | remaining = null; | ||
8864 | foreach (object part in parts) | ||
8068 | { | 8865 | { |
8069 | case ScriptBaseClass.KFM_MODE: | 8866 | if (part is SceneObjectPart) |
8070 | if (remain < 1) | 8867 | remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); |
8071 | break; | 8868 | else |
8072 | int modeval = (int)options.GetLSLIntegerItem(idx++); | 8869 | remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); |
8073 | switch(modeval) | ||
8074 | { | ||
8075 | case ScriptBaseClass.KFM_FORWARD: | ||
8076 | mode = KeyframeMotion.PlayMode.Forward; | ||
8077 | break; | ||
8078 | case ScriptBaseClass.KFM_REVERSE: | ||
8079 | mode = KeyframeMotion.PlayMode.Reverse; | ||
8080 | break; | ||
8081 | case ScriptBaseClass.KFM_LOOP: | ||
8082 | mode = KeyframeMotion.PlayMode.Loop; | ||
8083 | break; | ||
8084 | case ScriptBaseClass.KFM_PING_PONG: | ||
8085 | mode = KeyframeMotion.PlayMode.PingPong; | ||
8086 | break; | ||
8087 | } | ||
8088 | break; | ||
8089 | case ScriptBaseClass.KFM_DATA: | ||
8090 | if (remain < 1) | ||
8091 | break; | ||
8092 | int dataval = (int)options.GetLSLIntegerItem(idx++); | ||
8093 | data = (KeyframeMotion.DataFormat)dataval; | ||
8094 | break; | ||
8095 | } | 8870 | } |
8096 | } | 8871 | } |
8872 | } | ||
8873 | } | ||
8097 | 8874 | ||
8098 | group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); | 8875 | public LSL_List llGetPhysicsMaterial() |
8876 | { | ||
8877 | LSL_List result = new LSL_List(); | ||
8099 | 8878 | ||
8100 | idx = 0; | 8879 | result.Add(new LSL_Float(m_host.GravityModifier)); |
8880 | result.Add(new LSL_Float(m_host.Restitution)); | ||
8881 | result.Add(new LSL_Float(m_host.Friction)); | ||
8882 | result.Add(new LSL_Float(m_host.Density)); | ||
8101 | 8883 | ||
8102 | int elemLength = 2; | 8884 | return result; |
8103 | if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) | 8885 | } |
8104 | elemLength = 3; | ||
8105 | 8886 | ||
8106 | List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); | 8887 | private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, |
8107 | while (idx < frames.Data.Length) | 8888 | float material_density, float material_friction, |
8108 | { | 8889 | float material_restitution, float material_gravity_modifier) |
8109 | int remain = frames.Data.Length - idx; | 8890 | { |
8891 | ExtraPhysicsData physdata = new ExtraPhysicsData(); | ||
8892 | physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType; | ||
8893 | physdata.Density = part.Density; | ||
8894 | physdata.Friction = part.Friction; | ||
8895 | physdata.Bounce = part.Restitution; | ||
8896 | physdata.GravitationModifier = part.GravityModifier; | ||
8110 | 8897 | ||
8111 | if (remain < elemLength) | 8898 | if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0) |
8112 | break; | 8899 | physdata.Density = material_density; |
8900 | if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0) | ||
8901 | physdata.Friction = material_friction; | ||
8902 | if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0) | ||
8903 | physdata.Bounce = material_restitution; | ||
8904 | if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0) | ||
8905 | physdata.GravitationModifier = material_gravity_modifier; | ||
8113 | 8906 | ||
8114 | KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); | 8907 | part.UpdateExtraPhysics(physdata); |
8115 | frame.Position = null; | 8908 | } |
8116 | frame.Rotation = null; | ||
8117 | 8909 | ||
8118 | if ((data & KeyframeMotion.DataFormat.Translation) != 0) | 8910 | public void llSetPhysicsMaterial(int material_bits, |
8119 | { | 8911 | float material_gravity_modifier, float material_restitution, |
8120 | LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); | 8912 | float material_friction, float material_density) |
8121 | frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); | 8913 | { |
8122 | } | 8914 | SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); |
8123 | if ((data & KeyframeMotion.DataFormat.Rotation) != 0) | 8915 | } |
8124 | { | ||
8125 | LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); | ||
8126 | Quaternion q = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); | ||
8127 | q.Normalize(); | ||
8128 | frame.Rotation = q; | ||
8129 | } | ||
8130 | 8916 | ||
8131 | float tempf = (float)frames.GetLSLFloatItem(idx++); | 8917 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
8132 | frame.TimeMS = (int)(tempf * 1000.0f); | 8918 | { |
8919 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); | ||
8920 | llSetLinkPrimitiveParamsFast(linknumber, rules); | ||
8921 | ScriptSleep(200); | ||
8922 | } | ||
8133 | 8923 | ||
8134 | keyframes.Add(frame); | 8924 | // vector up using libomv (c&p from sop ) |
8135 | } | 8925 | // vector up rotated by r |
8926 | private Vector3 Zrot(Quaternion r) | ||
8927 | { | ||
8928 | double x, y, z, m; | ||
8136 | 8929 | ||
8137 | group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); | 8930 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; |
8138 | group.RootPart.KeyframeMotion.Start(); | 8931 | if (Math.Abs(1.0 - m) > 0.000001) |
8139 | } | ||
8140 | else | ||
8141 | { | 8932 | { |
8142 | if (group.RootPart.KeyframeMotion == null) | 8933 | m = 1.0 / Math.Sqrt(m); |
8143 | return; | 8934 | r.X *= (float)m; |
8144 | 8935 | r.Y *= (float)m; | |
8145 | if (options.Data.Length == 0) | 8936 | r.Z *= (float)m; |
8146 | { | 8937 | r.W *= (float)m; |
8147 | group.RootPart.KeyframeMotion.Stop(); | 8938 | } |
8148 | return; | ||
8149 | } | ||
8150 | |||
8151 | int idx = 0; | ||
8152 | 8939 | ||
8153 | while (idx < options.Data.Length) | 8940 | x = 2 * (r.X * r.Z + r.Y * r.W); |
8154 | { | 8941 | y = 2 * (-r.X * r.W + r.Y * r.Z); |
8155 | int option = (int)options.GetLSLIntegerItem(idx++); | 8942 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; |
8156 | 8943 | ||
8157 | switch (option) | 8944 | return new Vector3((float)x, (float)y, (float)z); |
8158 | { | ||
8159 | case ScriptBaseClass.KFM_COMMAND: | ||
8160 | int cmd = (int)options.GetLSLIntegerItem(idx++); | ||
8161 | switch (cmd) | ||
8162 | { | ||
8163 | case ScriptBaseClass.KFM_CMD_PLAY: | ||
8164 | group.RootPart.KeyframeMotion.Start(); | ||
8165 | break; | ||
8166 | case ScriptBaseClass.KFM_CMD_STOP: | ||
8167 | group.RootPart.KeyframeMotion.Stop(); | ||
8168 | break; | ||
8169 | case ScriptBaseClass.KFM_CMD_PAUSE: | ||
8170 | group.RootPart.KeyframeMotion.Pause(); | ||
8171 | break; | ||
8172 | } | ||
8173 | break; | ||
8174 | } | ||
8175 | } | ||
8176 | } | ||
8177 | } | 8945 | } |
8178 | 8946 | ||
8179 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) | 8947 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) |
8180 | { | 8948 | { |
8949 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
8950 | return null; | ||
8951 | |||
8181 | int idx = 0; | 8952 | int idx = 0; |
8182 | int idxStart = 0; | 8953 | int idxStart = 0; |
8183 | 8954 | ||
8955 | SceneObjectGroup parentgrp = part.ParentGroup; | ||
8956 | |||
8184 | bool positionChanged = false; | 8957 | bool positionChanged = false; |
8185 | LSL_Vector currentPosition = GetPartLocalPos(part); | 8958 | LSL_Vector currentPosition = GetPartLocalPos(part); |
8186 | 8959 | ||
@@ -8204,6 +8977,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8204 | if (remain < 1) | 8977 | if (remain < 1) |
8205 | return new LSL_List(); | 8978 | return new LSL_List(); |
8206 | 8979 | ||
8980 | <<<<<<< HEAD | ||
8207 | try | 8981 | try |
8208 | { | 8982 | { |
8209 | v = rules.GetVector3Item(idx++); | 8983 | v = rules.GetVector3Item(idx++); |
@@ -8216,8 +8990,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8216 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POS_LOCAL: arg #{1} - parameter 1 must be vector", rulesParsed, idx - idxStart - 1)); | 8990 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_POS_LOCAL: arg #{1} - parameter 1 must be vector", rulesParsed, idx - idxStart - 1)); |
8217 | return new LSL_List(); | 8991 | return new LSL_List(); |
8218 | } | 8992 | } |
8993 | ======= | ||
8994 | v=rules.GetVector3Item(idx++); | ||
8995 | if (part.IsRoot && !part.ParentGroup.IsAttachment) | ||
8996 | currentPosition = GetSetPosTarget(part, v, currentPosition, true); | ||
8997 | else | ||
8998 | currentPosition = GetSetPosTarget(part, v, currentPosition, false); | ||
8999 | >>>>>>> avn/ubitvar | ||
8219 | positionChanged = true; | 9000 | positionChanged = true; |
8220 | currentPosition = GetSetPosTarget(part, v, currentPosition); | ||
8221 | 9001 | ||
8222 | break; | 9002 | break; |
8223 | case ScriptBaseClass.PRIM_SIZE: | 9003 | case ScriptBaseClass.PRIM_SIZE: |
@@ -8242,7 +9022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8242 | return new LSL_List(); | 9022 | return new LSL_List(); |
8243 | } | 9023 | } |
8244 | // try to let this work as in SL... | 9024 | // try to let this work as in SL... |
8245 | if (part.ParentID == 0) | 9025 | if (part.ParentID == 0 || (part.ParentGroup != null && part == part.ParentGroup.RootPart)) |
8246 | { | 9026 | { |
8247 | // special case: If we are root, rotate complete SOG to new rotation | 9027 | // special case: If we are root, rotate complete SOG to new rotation |
8248 | SetRot(part, q); | 9028 | SetRot(part, q); |
@@ -9243,7 +10023,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9243 | 10023 | ||
9244 | break; | 10024 | break; |
9245 | 10025 | ||
10026 | <<<<<<< HEAD | ||
9246 | case ScriptBaseClass.PRIM_TEMP_ON_REZ: | 10027 | case ScriptBaseClass.PRIM_TEMP_ON_REZ: |
10028 | ======= | ||
10029 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
10030 | if (remain < 5) | ||
10031 | return null; | ||
10032 | |||
10033 | int material_bits = rules.GetLSLIntegerItem(idx++); | ||
10034 | float material_density = (float)rules.GetLSLFloatItem(idx++); | ||
10035 | float material_friction = (float)rules.GetLSLFloatItem(idx++); | ||
10036 | float material_restitution = (float)rules.GetLSLFloatItem(idx++); | ||
10037 | float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++); | ||
10038 | |||
10039 | SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); | ||
10040 | |||
10041 | break; | ||
10042 | |||
10043 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
10044 | >>>>>>> avn/ubitvar | ||
9247 | if (remain < 1) | 10045 | if (remain < 1) |
9248 | return new LSL_List(); | 10046 | return new LSL_List(); |
9249 | string temp = rules.Data[idx++].ToString(); | 10047 | string temp = rules.Data[idx++].ToString(); |
@@ -9437,14 +10235,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9437 | if (part.ParentGroup.RootPart == part) | 10235 | if (part.ParentGroup.RootPart == part) |
9438 | { | 10236 | { |
9439 | SceneObjectGroup parent = part.ParentGroup; | 10237 | SceneObjectGroup parent = part.ParentGroup; |
9440 | parent.UpdateGroupPosition(currentPosition); | 10238 | Util.FireAndForget(delegate(object x) { |
10239 | parent.UpdateGroupPosition(currentPosition); | ||
10240 | }); | ||
9441 | } | 10241 | } |
9442 | else | 10242 | else |
9443 | { | 10243 | { |
9444 | part.OffsetPosition = currentPosition; | 10244 | part.OffsetPosition = currentPosition; |
9445 | SceneObjectGroup parent = part.ParentGroup; | 10245 | // SceneObjectGroup parent = part.ParentGroup; |
9446 | parent.HasGroupChanged = true; | 10246 | // parent.HasGroupChanged = true; |
9447 | parent.ScheduleGroupForTerseUpdate(); | 10247 | // parent.ScheduleGroupForTerseUpdate(); |
10248 | part.ScheduleTerseUpdate(); | ||
9448 | } | 10249 | } |
9449 | } | 10250 | } |
9450 | } | 10251 | } |
@@ -9596,10 +10397,111 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9596 | 10397 | ||
9597 | public LSL_String llXorBase64Strings(string str1, string str2) | 10398 | public LSL_String llXorBase64Strings(string str1, string str2) |
9598 | { | 10399 | { |
10400 | <<<<<<< HEAD | ||
9599 | m_host.AddScriptLPS(1); | 10401 | m_host.AddScriptLPS(1); |
9600 | Deprecated("llXorBase64Strings", "Use llXorBase64 instead"); | 10402 | Deprecated("llXorBase64Strings", "Use llXorBase64 instead"); |
9601 | ScriptSleep(m_sleepMsOnXorBase64Strings); | 10403 | ScriptSleep(m_sleepMsOnXorBase64Strings); |
9602 | return String.Empty; | 10404 | return String.Empty; |
10405 | ======= | ||
10406 | int padding = 0; | ||
10407 | |||
10408 | string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
10409 | |||
10410 | ScriptSleep(300); | ||
10411 | m_host.AddScriptLPS(1); | ||
10412 | |||
10413 | if (str1 == String.Empty) | ||
10414 | return String.Empty; | ||
10415 | if (str2 == String.Empty) | ||
10416 | return str1; | ||
10417 | |||
10418 | int len = str2.Length; | ||
10419 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
10420 | { | ||
10421 | while (str2.EndsWith("=")) | ||
10422 | str2 = str2.Substring(0, str2.Length - 1); | ||
10423 | |||
10424 | len = str2.Length; | ||
10425 | int mod = len % 4; | ||
10426 | |||
10427 | if (mod == 1) | ||
10428 | str2 = str2.Substring(0, str2.Length - 1); | ||
10429 | else if (mod == 2) | ||
10430 | str2 += "=="; | ||
10431 | else if (mod == 3) | ||
10432 | str2 += "="; | ||
10433 | } | ||
10434 | |||
10435 | byte[] data1; | ||
10436 | byte[] data2; | ||
10437 | try | ||
10438 | { | ||
10439 | data1 = Convert.FromBase64String(str1); | ||
10440 | data2 = Convert.FromBase64String(str2); | ||
10441 | } | ||
10442 | catch (Exception) | ||
10443 | { | ||
10444 | return new LSL_String(String.Empty); | ||
10445 | } | ||
10446 | |||
10447 | // For cases where the decoded length of s2 is greater | ||
10448 | // than the decoded length of s1, simply perform a normal | ||
10449 | // decode and XOR | ||
10450 | // | ||
10451 | /* | ||
10452 | if (data2.Length >= data1.Length) | ||
10453 | { | ||
10454 | for (int pos = 0 ; pos < data1.Length ; pos++ ) | ||
10455 | data1[pos] ^= data2[pos]; | ||
10456 | |||
10457 | return Convert.ToBase64String(data1); | ||
10458 | } | ||
10459 | */ | ||
10460 | |||
10461 | // Remove padding | ||
10462 | while (str1.EndsWith("=")) | ||
10463 | { | ||
10464 | str1 = str1.Substring(0, str1.Length - 1); | ||
10465 | padding++; | ||
10466 | } | ||
10467 | while (str2.EndsWith("=")) | ||
10468 | str2 = str2.Substring(0, str2.Length - 1); | ||
10469 | |||
10470 | byte[] d1 = new byte[str1.Length]; | ||
10471 | byte[] d2 = new byte[str2.Length]; | ||
10472 | |||
10473 | for (int i = 0 ; i < str1.Length ; i++) | ||
10474 | { | ||
10475 | int idx = b64.IndexOf(str1.Substring(i, 1)); | ||
10476 | if (idx == -1) | ||
10477 | idx = 0; | ||
10478 | d1[i] = (byte)idx; | ||
10479 | } | ||
10480 | |||
10481 | for (int i = 0 ; i < str2.Length ; i++) | ||
10482 | { | ||
10483 | int idx = b64.IndexOf(str2.Substring(i, 1)); | ||
10484 | if (idx == -1) | ||
10485 | idx = 0; | ||
10486 | d2[i] = (byte)idx; | ||
10487 | } | ||
10488 | |||
10489 | string output = String.Empty; | ||
10490 | |||
10491 | for (int pos = 0 ; pos < d1.Length ; pos++) | ||
10492 | output += b64[d1[pos] ^ d2[pos % d2.Length]]; | ||
10493 | |||
10494 | // Here's a funny thing: LL blithely violate the base64 | ||
10495 | // standard pretty much everywhere. Here, padding is | ||
10496 | // added only if the first input string had it, rather | ||
10497 | // than when the data actually needs it. This can result | ||
10498 | // in invalid base64 being returned. Go figure. | ||
10499 | |||
10500 | while (padding-- > 0) | ||
10501 | output += "="; | ||
10502 | |||
10503 | return output; | ||
10504 | >>>>>>> avn/ubitvar | ||
9603 | } | 10505 | } |
9604 | 10506 | ||
9605 | public void llRemoteDataSetRegion() | 10507 | public void llRemoteDataSetRegion() |
@@ -9724,8 +10626,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9724 | public LSL_Integer llGetNumberOfPrims() | 10626 | public LSL_Integer llGetNumberOfPrims() |
9725 | { | 10627 | { |
9726 | m_host.AddScriptLPS(1); | 10628 | m_host.AddScriptLPS(1); |
9727 | 10629 | int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; | |
9728 | return m_host.ParentGroup.PrimCount + m_host.ParentGroup.GetSittingAvatarsCount(); | 10630 | |
10631 | return m_host.ParentGroup.PrimCount + avatarCount; | ||
9729 | } | 10632 | } |
9730 | 10633 | ||
9731 | /// <summary> | 10634 | /// <summary> |
@@ -9770,10 +10673,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9770 | 10673 | ||
9771 | // Initialize but break if no target | 10674 | // Initialize but break if no target |
9772 | LSL_List result = new LSL_List(); | 10675 | LSL_List result = new LSL_List(); |
10676 | <<<<<<< HEAD | ||
9773 | int groupCount = 0; | 10677 | int groupCount = 0; |
9774 | int partCount = 0; | 10678 | int partCount = 0; |
9775 | int vertexCount = 0; | 10679 | int vertexCount = 0; |
9776 | if (target == null && agent == null) | 10680 | if (target == null && agent == null) |
10681 | ======= | ||
10682 | |||
10683 | // If the ID is not valid, return null result | ||
10684 | if (!UUID.TryParse(obj, out objID)) | ||
10685 | >>>>>>> avn/ubitvar | ||
9777 | { | 10686 | { |
9778 | result.Add(new LSL_Vector()); | 10687 | result.Add(new LSL_Vector()); |
9779 | result.Add(new LSL_Vector()); | 10688 | result.Add(new LSL_Vector()); |
@@ -9781,6 +10690,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9781 | result.Add(new LSL_Vector((float)groupCount, (float)partCount, (float)vertexCount)); | 10690 | result.Add(new LSL_Vector((float)groupCount, (float)partCount, (float)vertexCount)); |
9782 | return result; | 10691 | return result; |
9783 | } | 10692 | } |
10693 | <<<<<<< HEAD | ||
9784 | Vector3 minPosition = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); | 10694 | Vector3 minPosition = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); |
9785 | Vector3 maxPosition = new Vector3(float.MinValue, float.MinValue, float.MinValue); | 10695 | Vector3 maxPosition = new Vector3(float.MinValue, float.MinValue, float.MinValue); |
9786 | 10696 | ||
@@ -9901,10 +10811,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9901 | if (m_useSimpleBoxesInGetBoundingBox || primMesher == null) | 10811 | if (m_useSimpleBoxesInGetBoundingBox || primMesher == null) |
9902 | { | 10812 | { |
9903 | AddBoundingBoxOfSimpleBox(lower, upper, offset, sp.Rotation, hasParent, ref minPosition, ref maxPosition, ref vertexCount); | 10813 | AddBoundingBoxOfSimpleBox(lower, upper, offset, sp.Rotation, hasParent, ref minPosition, ref maxPosition, ref vertexCount); |
10814 | ======= | ||
10815 | |||
10816 | // Check if this is an attached prim. If so, replace | ||
10817 | // the UUID with the avatar UUID and report it's bounding box | ||
10818 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
10819 | if (part != null && part.ParentGroup.IsAttachment) | ||
10820 | objID = part.ParentGroup.AttachedAvatar; | ||
10821 | |||
10822 | // Find out if this is an avatar ID. If so, return it's box | ||
10823 | ScenePresence presence = World.GetScenePresence(objID); | ||
10824 | if (presence != null) | ||
10825 | { | ||
10826 | // As per LSL Wiki, there is no difference between sitting | ||
10827 | // and standing avatar since server 1.36 | ||
10828 | LSL_Vector lower; | ||
10829 | LSL_Vector upper; | ||
10830 | |||
10831 | Vector3 box = presence.Appearance.AvatarBoxSize * 0.5f; | ||
10832 | |||
10833 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID | ||
10834 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
10835 | /* | ||
10836 | { | ||
10837 | // This is for ground sitting avatars | ||
10838 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
10839 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
10840 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
10841 | } | ||
10842 | else | ||
10843 | { | ||
10844 | // This is for standing/flying avatars | ||
10845 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
10846 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
10847 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
10848 | } | ||
10849 | |||
10850 | // Adjust to the documented error offsets (see LSL Wiki) | ||
10851 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
10852 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
10853 | */ | ||
10854 | { | ||
10855 | // This is for ground sitting avatars TODO! | ||
10856 | lower = new LSL_Vector(-box.X - 0.1125, -box.Y, box.Z * -1.0f); | ||
10857 | upper = new LSL_Vector(box.X + 0.1125, box.Y, box.Z * -1.0f); | ||
10858 | >>>>>>> avn/ubitvar | ||
9904 | } | 10859 | } |
9905 | // Do the full mounty | 10860 | // Do the full mounty |
9906 | else | 10861 | else |
9907 | { | 10862 | { |
10863 | <<<<<<< HEAD | ||
9908 | // Prim shapes don't do center offsets, so add it here. | 10864 | // Prim shapes don't do center offsets, so add it here. |
9909 | offset = offset + (lower + upper) * 0.5f * sp.Rotation; | 10865 | offset = offset + (lower + upper) * 0.5f * sp.Rotation; |
9910 | Primitive omvPrim = MakeOpenMetaversePrim(upper - lower, offset, sp.Rotation, ScriptBaseClass.PRIM_TYPE_SPHERE); | 10866 | Primitive omvPrim = MakeOpenMetaversePrim(upper - lower, offset, sp.Rotation, ScriptBaseClass.PRIM_TYPE_SPHERE); |
@@ -9960,6 +10916,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9960 | { | 10916 | { |
9961 | lower = new Vector3(m_lABB1StdX0, m_lABB1StdY0, m_lABB1StdZ0 + m_lABB1StdZ1 * height); | 10917 | lower = new Vector3(m_lABB1StdX0, m_lABB1StdY0, m_lABB1StdZ0 + m_lABB1StdZ1 * height); |
9962 | upper = new Vector3(m_lABB2StdX0, m_lABB2StdY0, m_lABB2StdZ0 + m_lABB2StdZ1 * height); | 10918 | upper = new Vector3(m_lABB2StdX0, m_lABB2StdY0, m_lABB2StdZ0 + m_lABB2StdZ1 * height); |
10919 | ======= | ||
10920 | // This is for standing/flying avatars | ||
10921 | lower = new LSL_Vector(-box.X, -box.Y, -box.Z); | ||
10922 | upper = new LSL_Vector(box.X, box.Y, box.Z); | ||
10923 | } | ||
10924 | |||
10925 | if (lower.x > upper.x) | ||
10926 | lower.x = upper.x; | ||
10927 | if (lower.y > upper.y) | ||
10928 | lower.y = upper.y; | ||
10929 | if (lower.z > upper.z) | ||
10930 | lower.z = upper.z; | ||
10931 | |||
10932 | result.Add(lower); | ||
10933 | result.Add(upper); | ||
10934 | return result; | ||
10935 | } | ||
10936 | |||
10937 | part = World.GetSceneObjectPart(objID); | ||
10938 | // Currently only works for single prims without a sitting avatar | ||
10939 | if (part != null) | ||
10940 | { | ||
10941 | float minX; | ||
10942 | float maxX; | ||
10943 | float minY; | ||
10944 | float maxY; | ||
10945 | float minZ; | ||
10946 | float maxZ; | ||
10947 | |||
10948 | // This BBox is in sim coordinates, with the offset being | ||
10949 | // a contained point. | ||
10950 | Vector3[] offsets = Scene.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
10951 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
10952 | |||
10953 | minX -= offsets[0].X; | ||
10954 | maxX -= offsets[0].X; | ||
10955 | minY -= offsets[0].Y; | ||
10956 | maxY -= offsets[0].Y; | ||
10957 | minZ -= offsets[0].Z; | ||
10958 | maxZ -= offsets[0].Z; | ||
10959 | |||
10960 | LSL_Vector lower; | ||
10961 | LSL_Vector upper; | ||
10962 | |||
10963 | // Adjust to the documented error offsets (see LSL Wiki) | ||
10964 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
10965 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
10966 | |||
10967 | if (lower.x > upper.x) | ||
10968 | lower.x = upper.x; | ||
10969 | if (lower.y > upper.y) | ||
10970 | lower.y = upper.y; | ||
10971 | if (lower.z > upper.z) | ||
10972 | lower.z = upper.z; | ||
10973 | |||
10974 | result.Add(lower); | ||
10975 | result.Add(upper); | ||
10976 | return result; | ||
10977 | >>>>>>> avn/ubitvar | ||
9963 | } | 10978 | } |
9964 | } | 10979 | } |
9965 | 10980 | ||
@@ -10166,8 +11181,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10166 | return new LSL_Vector(offset); | 11181 | return new LSL_Vector(offset); |
10167 | } | 11182 | } |
10168 | 11183 | ||
10169 | public LSL_List GetEntityParams(ISceneEntity entity, LSL_List rules) | 11184 | public LSL_List llGetPrimitiveParams(LSL_List rules) |
10170 | { | 11185 | { |
11186 | <<<<<<< HEAD | ||
10171 | LSL_List result = new LSL_List(); | 11187 | LSL_List result = new LSL_List(); |
10172 | LSL_List remaining; | 11188 | LSL_List remaining; |
10173 | 11189 | ||
@@ -10179,57 +11195,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10179 | 11195 | ||
10180 | if (entity == null) | 11196 | if (entity == null) |
10181 | return result; | 11197 | return result; |
11198 | ======= | ||
11199 | m_host.AddScriptLPS(1); | ||
11200 | >>>>>>> avn/ubitvar | ||
10182 | 11201 | ||
10183 | if (entity is SceneObjectPart) | 11202 | LSL_List result = new LSL_List(); |
10184 | remaining = GetPrimParams((SceneObjectPart)entity, rules, ref result); | ||
10185 | else | ||
10186 | remaining = GetAgentParams((ScenePresence)entity, rules, ref result); | ||
10187 | 11203 | ||
10188 | if (remaining == null || remaining.Length < 2) | 11204 | LSL_List remaining = GetPrimParams(m_host, rules, ref result); |
10189 | return result; | ||
10190 | 11205 | ||
11206 | while ((object)remaining != null && remaining.Length > 2) | ||
11207 | { | ||
10191 | int linknumber = remaining.GetLSLIntegerItem(0); | 11208 | int linknumber = remaining.GetLSLIntegerItem(0); |
10192 | rules = remaining.GetSublist(1, -1); | 11209 | rules = remaining.GetSublist(1, -1); |
11210 | <<<<<<< HEAD | ||
10193 | entity = GetLinkEntity(m_host, linknumber); | 11211 | entity = GetLinkEntity(m_host, linknumber); |
10194 | } | 11212 | } |
10195 | } | 11213 | } |
11214 | ======= | ||
11215 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | ||
11216 | >>>>>>> avn/ubitvar | ||
10196 | 11217 | ||
10197 | public LSL_List llGetPrimitiveParams(LSL_List rules) | 11218 | foreach (SceneObjectPart part in parts) |
10198 | { | 11219 | remaining = GetPrimParams(part, rules, ref result); |
10199 | m_host.AddScriptLPS(1); | 11220 | } |
10200 | 11221 | ||
10201 | return GetEntityParams(m_host, rules); | 11222 | return result; |
10202 | } | 11223 | } |
10203 | 11224 | ||
10204 | public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) | 11225 | public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) |
10205 | { | 11226 | { |
10206 | m_host.AddScriptLPS(1); | 11227 | m_host.AddScriptLPS(1); |
10207 | 11228 | ||
11229 | <<<<<<< HEAD | ||
10208 | return GetEntityParams(GetLinkEntity(m_host, linknumber), rules); | 11230 | return GetEntityParams(GetLinkEntity(m_host, linknumber), rules); |
10209 | } | 11231 | } |
11232 | ======= | ||
11233 | // acording to SL wiki this must indicate a single link number or link_root or link_this. | ||
11234 | // keep other options as before | ||
11235 | >>>>>>> avn/ubitvar | ||
10210 | 11236 | ||
10211 | public LSL_Vector GetAgentSize(ScenePresence sp) | 11237 | List<SceneObjectPart> parts; |
10212 | { | 11238 | List<ScenePresence> avatars; |
10213 | return new LSL_Vector(0.45, 0.6, sp.Appearance.AvatarHeight); | 11239 | |
10214 | } | 11240 | LSL_List res = new LSL_List(); |
11241 | LSL_List remaining = null; | ||
10215 | 11242 | ||
10216 | /// <summary> | 11243 | while (rules.Length > 0) |
10217 | /// Gets params for a seated avatar in a linkset. | ||
10218 | /// </summary> | ||
10219 | /// <returns></returns> | ||
10220 | /// <param name='sp'></param> | ||
10221 | /// <param name='rules'></param> | ||
10222 | /// <param name='res'></param> | ||
10223 | public LSL_List GetAgentParams(ScenePresence sp, LSL_List rules, ref LSL_List res) | ||
10224 | { | ||
10225 | int idx = 0; | ||
10226 | while (idx < rules.Length) | ||
10227 | { | 11244 | { |
10228 | int code = (int)rules.GetLSLIntegerItem(idx++); | 11245 | parts = GetLinkParts(linknumber); |
10229 | int remain = rules.Length-idx; | 11246 | avatars = GetLinkAvatars(linknumber); |
10230 | 11247 | ||
10231 | switch (code) | 11248 | remaining = null; |
11249 | foreach (SceneObjectPart part in parts) | ||
10232 | { | 11250 | { |
11251 | <<<<<<< HEAD | ||
10233 | case (int)ScriptBaseClass.PRIM_MATERIAL: | 11252 | case (int)ScriptBaseClass.PRIM_MATERIAL: |
10234 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MATERIAL_FLESH)); | 11253 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MATERIAL_FLESH)); |
10235 | break; | 11254 | break; |
@@ -10376,17 +11395,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10376 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 11395 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
10377 | if(remain < 3) | 11396 | if(remain < 3) |
10378 | return new LSL_List(); | 11397 | return new LSL_List(); |
11398 | ======= | ||
11399 | remaining = GetPrimParams(part, rules, ref res); | ||
11400 | } | ||
11401 | foreach (ScenePresence avatar in avatars) | ||
11402 | { | ||
11403 | remaining = GetPrimParams(avatar, rules, ref res); | ||
11404 | } | ||
11405 | >>>>>>> avn/ubitvar | ||
10379 | 11406 | ||
10380 | return rules.GetSublist(idx, -1); | 11407 | if ((object)remaining != null && remaining.Length > 0) |
11408 | { | ||
11409 | linknumber = remaining.GetLSLIntegerItem(0); | ||
11410 | rules = remaining.GetSublist(1, -1); | ||
10381 | } | 11411 | } |
11412 | else | ||
11413 | break; | ||
10382 | } | 11414 | } |
10383 | 11415 | ||
11416 | <<<<<<< HEAD | ||
10384 | return new LSL_List(); | 11417 | return new LSL_List(); |
11418 | ======= | ||
11419 | return res; | ||
11420 | >>>>>>> avn/ubitvar | ||
10385 | } | 11421 | } |
10386 | 11422 | ||
10387 | public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res) | 11423 | public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res) |
10388 | { | 11424 | { |
10389 | int idx = 0; | 11425 | int idx=0; |
10390 | while (idx < rules.Length) | 11426 | while (idx < rules.Length) |
10391 | { | 11427 | { |
10392 | int code = (int)rules.GetLSLIntegerItem(idx++); | 11428 | int code = (int)rules.GetLSLIntegerItem(idx++); |
@@ -10420,19 +11456,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10420 | break; | 11456 | break; |
10421 | 11457 | ||
10422 | case (int)ScriptBaseClass.PRIM_POSITION: | 11458 | case (int)ScriptBaseClass.PRIM_POSITION: |
10423 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition); | 11459 | LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, |
10424 | 11460 | part.AbsolutePosition.Y, | |
10425 | // For some reason, the part.AbsolutePosition.* values do not change if the | 11461 | part.AbsolutePosition.Z); |
10426 | // linkset is rotated; they always reflect the child prim's world position | ||
10427 | // as though the linkset is unrotated. This is incompatible behavior with SL's | ||
10428 | // implementation, so will break scripts imported from there (not to mention it | ||
10429 | // makes it more difficult to determine a child prim's actual inworld position). | ||
10430 | if (!part.IsRoot) | ||
10431 | { | ||
10432 | LSL_Vector rootPos = new LSL_Vector(m_host.ParentGroup.AbsolutePosition); | ||
10433 | v = ((v - rootPos) * llGetRootRotation()) + rootPos; | ||
10434 | } | ||
10435 | |||
10436 | res.Add(v); | 11462 | res.Add(v); |
10437 | break; | 11463 | break; |
10438 | 11464 | ||
@@ -10606,30 +11632,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10606 | if (remain < 1) | 11632 | if (remain < 1) |
10607 | return new LSL_List(); | 11633 | return new LSL_List(); |
10608 | 11634 | ||
10609 | face=(int)rules.GetLSLIntegerItem(idx++); | 11635 | face = (int)rules.GetLSLIntegerItem(idx++); |
10610 | 11636 | ||
10611 | tex = part.Shape.Textures; | 11637 | tex = part.Shape.Textures; |
11638 | int shiny; | ||
10612 | if (face == ScriptBaseClass.ALL_SIDES) | 11639 | if (face == ScriptBaseClass.ALL_SIDES) |
10613 | { | 11640 | { |
10614 | for (face = 0; face < GetNumberOfSides(part); face++) | 11641 | for (face = 0; face < GetNumberOfSides(part); face++) |
10615 | { | 11642 | { |
10616 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 11643 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
10617 | // Convert Shininess to PRIM_SHINY_* | 11644 | if (shinyness == Shininess.High) |
10618 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | 11645 | { |
10619 | // PRIM_BUMP_* | 11646 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
10620 | res.Add(new LSL_Integer((int)texface.Bump)); | 11647 | } |
11648 | else if (shinyness == Shininess.Medium) | ||
11649 | { | ||
11650 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
11651 | } | ||
11652 | else if (shinyness == Shininess.Low) | ||
11653 | { | ||
11654 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
11655 | } | ||
11656 | else | ||
11657 | { | ||
11658 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
11659 | } | ||
11660 | res.Add(new LSL_Integer(shiny)); | ||
11661 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
10621 | } | 11662 | } |
10622 | } | 11663 | } |
10623 | else | 11664 | else |
10624 | { | 11665 | { |
10625 | if (face >= 0 && face < GetNumberOfSides(part)) | 11666 | Shininess shinyness = tex.GetFace((uint)face).Shiny; |
11667 | if (shinyness == Shininess.High) | ||
10626 | { | 11668 | { |
10627 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 11669 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; |
10628 | // Convert Shininess to PRIM_SHINY_* | ||
10629 | res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); | ||
10630 | // PRIM_BUMP_* | ||
10631 | res.Add(new LSL_Integer((int)texface.Bump)); | ||
10632 | } | 11670 | } |
11671 | else if (shinyness == Shininess.Medium) | ||
11672 | { | ||
11673 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
11674 | } | ||
11675 | else if (shinyness == Shininess.Low) | ||
11676 | { | ||
11677 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
11678 | } | ||
11679 | else | ||
11680 | { | ||
11681 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
11682 | } | ||
11683 | res.Add(new LSL_Integer(shiny)); | ||
11684 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
10633 | } | 11685 | } |
10634 | break; | 11686 | break; |
10635 | 11687 | ||
@@ -10640,21 +11692,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10640 | face = (int)rules.GetLSLIntegerItem(idx++); | 11692 | face = (int)rules.GetLSLIntegerItem(idx++); |
10641 | 11693 | ||
10642 | tex = part.Shape.Textures; | 11694 | tex = part.Shape.Textures; |
11695 | int fullbright; | ||
10643 | if (face == ScriptBaseClass.ALL_SIDES) | 11696 | if (face == ScriptBaseClass.ALL_SIDES) |
10644 | { | 11697 | { |
10645 | for (face = 0; face < GetNumberOfSides(part); face++) | 11698 | for (face = 0; face < GetNumberOfSides(part); face++) |
10646 | { | 11699 | { |
10647 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 11700 | if (tex.GetFace((uint)face).Fullbright == true) |
10648 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 11701 | { |
11702 | fullbright = ScriptBaseClass.TRUE; | ||
11703 | } | ||
11704 | else | ||
11705 | { | ||
11706 | fullbright = ScriptBaseClass.FALSE; | ||
11707 | } | ||
11708 | res.Add(new LSL_Integer(fullbright)); | ||
10649 | } | 11709 | } |
10650 | } | 11710 | } |
10651 | else | 11711 | else |
10652 | { | 11712 | { |
10653 | if (face >= 0 && face < GetNumberOfSides(part)) | 11713 | if (tex.GetFace((uint)face).Fullbright == true) |
10654 | { | 11714 | { |
10655 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 11715 | fullbright = ScriptBaseClass.TRUE; |
10656 | res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); | 11716 | } |
11717 | else | ||
11718 | { | ||
11719 | fullbright = ScriptBaseClass.FALSE; | ||
10657 | } | 11720 | } |
11721 | res.Add(new LSL_Integer(fullbright)); | ||
10658 | } | 11722 | } |
10659 | break; | 11723 | break; |
10660 | 11724 | ||
@@ -10676,27 +11740,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10676 | break; | 11740 | break; |
10677 | 11741 | ||
10678 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 11742 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
11743 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
10679 | if (remain < 1) | 11744 | if (remain < 1) |
10680 | return new LSL_List(); | 11745 | return new LSL_List(); |
10681 | 11746 | ||
10682 | face=(int)rules.GetLSLIntegerItem(idx++); | 11747 | face = (int)rules.GetLSLIntegerItem(idx++); |
10683 | 11748 | ||
10684 | tex = part.Shape.Textures; | 11749 | tex = part.Shape.Textures; |
10685 | if (face == ScriptBaseClass.ALL_SIDES) | 11750 | if (face == ScriptBaseClass.ALL_SIDES) |
10686 | { | 11751 | { |
10687 | for (face = 0; face < GetNumberOfSides(part); face++) | 11752 | for (face = 0; face < GetNumberOfSides(part); face++) |
10688 | { | 11753 | { |
10689 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 11754 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
10690 | // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. | 11755 | { |
10691 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 11756 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
11757 | } | ||
11758 | else | ||
11759 | { | ||
11760 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
11761 | } | ||
10692 | } | 11762 | } |
10693 | } | 11763 | } |
10694 | else | 11764 | else |
10695 | { | 11765 | { |
10696 | if (face >= 0 && face < GetNumberOfSides(part)) | 11766 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) |
10697 | { | 11767 | { |
10698 | MappingType texgen = tex.GetFace((uint)face).TexMapType; | 11768 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); |
10699 | res.Add(new LSL_Integer((uint)texgen >> 1)); | 11769 | } |
11770 | else | ||
11771 | { | ||
11772 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
10700 | } | 11773 | } |
10701 | } | 11774 | } |
10702 | break; | 11775 | break; |
@@ -10720,24 +11793,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10720 | if (remain < 1) | 11793 | if (remain < 1) |
10721 | return new LSL_List(); | 11794 | return new LSL_List(); |
10722 | 11795 | ||
10723 | face=(int)rules.GetLSLIntegerItem(idx++); | 11796 | face = (int)rules.GetLSLIntegerItem(idx++); |
10724 | 11797 | ||
10725 | tex = part.Shape.Textures; | 11798 | tex = part.Shape.Textures; |
11799 | float primglow; | ||
10726 | if (face == ScriptBaseClass.ALL_SIDES) | 11800 | if (face == ScriptBaseClass.ALL_SIDES) |
10727 | { | 11801 | { |
10728 | for (face = 0; face < GetNumberOfSides(part); face++) | 11802 | for (face = 0; face < GetNumberOfSides(part); face++) |
10729 | { | 11803 | { |
10730 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 11804 | primglow = tex.GetFace((uint)face).Glow; |
10731 | res.Add(new LSL_Float(texface.Glow)); | 11805 | res.Add(new LSL_Float(primglow)); |
10732 | } | 11806 | } |
10733 | } | 11807 | } |
10734 | else | 11808 | else |
10735 | { | 11809 | { |
10736 | if (face >= 0 && face < GetNumberOfSides(part)) | 11810 | primglow = tex.GetFace((uint)face).Glow; |
10737 | { | 11811 | res.Add(new LSL_Float(primglow)); |
10738 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
10739 | res.Add(new LSL_Float(texface.Glow)); | ||
10740 | } | ||
10741 | } | 11812 | } |
10742 | break; | 11813 | break; |
10743 | 11814 | ||
@@ -10749,15 +11820,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10749 | textColor.B)); | 11820 | textColor.B)); |
10750 | res.Add(new LSL_Float(1.0 - textColor.A)); | 11821 | res.Add(new LSL_Float(1.0 - textColor.A)); |
10751 | break; | 11822 | break; |
11823 | |||
10752 | case (int)ScriptBaseClass.PRIM_NAME: | 11824 | case (int)ScriptBaseClass.PRIM_NAME: |
10753 | res.Add(new LSL_String(part.Name)); | 11825 | res.Add(new LSL_String(part.Name)); |
10754 | break; | 11826 | break; |
11827 | |||
10755 | case (int)ScriptBaseClass.PRIM_DESC: | 11828 | case (int)ScriptBaseClass.PRIM_DESC: |
10756 | res.Add(new LSL_String(part.Description)); | 11829 | res.Add(new LSL_String(part.Description)); |
10757 | break; | 11830 | break; |
10758 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 11831 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
10759 | res.Add(new LSL_Rotation(part.RotationOffset)); | 11832 | res.Add(new LSL_Rotation(part.RotationOffset)); |
10760 | break; | 11833 | break; |
11834 | |||
10761 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 11835 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
10762 | res.Add(new LSL_Vector(GetPartLocalPos(part))); | 11836 | res.Add(new LSL_Vector(GetPartLocalPos(part))); |
10763 | break; | 11837 | break; |
@@ -11370,8 +12444,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11370 | // The function returns an ordered list | 12444 | // The function returns an ordered list |
11371 | // representing the tokens found in the supplied | 12445 | // representing the tokens found in the supplied |
11372 | // sources string. If two successive tokenizers | 12446 | // sources string. If two successive tokenizers |
11373 | // are encountered, then a NULL entry is added | 12447 | // are encountered, then a null-string entry is |
11374 | // to the list. | 12448 | // added to the list. |
11375 | // | 12449 | // |
11376 | // It is a precondition that the source and | 12450 | // It is a precondition that the source and |
11377 | // toekizer lisst are non-null. If they are null, | 12451 | // toekizer lisst are non-null. If they are null, |
@@ -11379,7 +12453,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11379 | // while their lengths are being determined. | 12453 | // while their lengths are being determined. |
11380 | // | 12454 | // |
11381 | // A small amount of working memoryis required | 12455 | // A small amount of working memoryis required |
11382 | // of approximately 8*#tokenizers. | 12456 | // of approximately 8*#tokenizers + 8*srcstrlen. |
11383 | // | 12457 | // |
11384 | // There are many ways in which this function | 12458 | // There are many ways in which this function |
11385 | // can be implemented, this implementation is | 12459 | // can be implemented, this implementation is |
@@ -11395,155 +12469,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11395 | // and eliminates redundant tokenizers as soon | 12469 | // and eliminates redundant tokenizers as soon |
11396 | // as is possible. | 12470 | // as is possible. |
11397 | // | 12471 | // |
11398 | // The implementation tries to avoid any copying | 12472 | // The implementation tries to minimize temporary |
11399 | // of arrays or other objects. | 12473 | // garbage generation. |
11400 | // </remarks> | 12474 | // </remarks> |
11401 | 12475 | ||
11402 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) | 12476 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) |
11403 | { | 12477 | { |
11404 | int beginning = 0; | 12478 | return ParseString2List(src, separators, spacers, true); |
11405 | int srclen = src.Length; | 12479 | } |
11406 | int seplen = separators.Length; | ||
11407 | object[] separray = separators.Data; | ||
11408 | int spclen = spacers.Length; | ||
11409 | object[] spcarray = spacers.Data; | ||
11410 | int mlen = seplen+spclen; | ||
11411 | |||
11412 | int[] offset = new int[mlen+1]; | ||
11413 | bool[] active = new bool[mlen]; | ||
11414 | |||
11415 | int best; | ||
11416 | int j; | ||
11417 | |||
11418 | // Initial capacity reduces resize cost | ||
11419 | 12480 | ||
11420 | LSL_List tokens = new LSL_List(); | 12481 | private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
12482 | { | ||
12483 | int srclen = src.Length; | ||
12484 | int seplen = separators.Length; | ||
12485 | object[] separray = separators.Data; | ||
12486 | int spclen = spacers.Length; | ||
12487 | object[] spcarray = spacers.Data; | ||
12488 | int dellen = 0; | ||
12489 | string[] delarray = new string[seplen+spclen]; | ||
11421 | 12490 | ||
11422 | // All entries are initially valid | 12491 | int outlen = 0; |
12492 | string[] outarray = new string[srclen*2+1]; | ||
11423 | 12493 | ||
11424 | for (int i = 0; i < mlen; i++) | 12494 | int i, j; |
11425 | active[i] = true; | 12495 | string d; |
11426 | 12496 | ||
11427 | offset[mlen] = srclen; | 12497 | m_host.AddScriptLPS(1); |
11428 | 12498 | ||
11429 | while (beginning < srclen) | 12499 | /* |
12500 | * Convert separator and spacer lists to C# strings. | ||
12501 | * Also filter out null strings so we don't hang. | ||
12502 | */ | ||
12503 | for (i = 0; i < seplen; i ++) | ||
11430 | { | 12504 | { |
12505 | d = separray[i].ToString(); | ||
12506 | if (d.Length > 0) | ||
12507 | { | ||
12508 | delarray[dellen++] = d; | ||
12509 | } | ||
12510 | } | ||
12511 | seplen = dellen; | ||
11431 | 12512 | ||
11432 | best = mlen; // as bad as it gets | 12513 | for (i = 0; i < spclen; i ++) |
12514 | { | ||
12515 | d = spcarray[i].ToString(); | ||
12516 | if (d.Length > 0) | ||
12517 | { | ||
12518 | delarray[dellen++] = d; | ||
12519 | } | ||
12520 | } | ||
11433 | 12521 | ||
11434 | // Scan for separators | 12522 | /* |
12523 | * Scan through source string from beginning to end. | ||
12524 | */ | ||
12525 | for (i = 0;;) | ||
12526 | { | ||
11435 | 12527 | ||
11436 | for (j = 0; j < seplen; j++) | 12528 | /* |
12529 | * Find earliest delimeter in src starting at i (if any). | ||
12530 | */ | ||
12531 | int earliestDel = -1; | ||
12532 | int earliestSrc = srclen; | ||
12533 | string earliestStr = null; | ||
12534 | for (j = 0; j < dellen; j ++) | ||
11437 | { | 12535 | { |
11438 | if (separray[j].ToString() == String.Empty) | 12536 | d = delarray[j]; |
11439 | active[j] = false; | 12537 | if (d != null) |
11440 | |||
11441 | if (active[j]) | ||
11442 | { | 12538 | { |
11443 | // scan all of the markers | 12539 | int index = src.IndexOf(d, i); |
11444 | if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) | 12540 | if (index < 0) |
11445 | { | 12541 | { |
11446 | // not present at all | 12542 | delarray[j] = null; // delim nowhere in src, don't check it anymore |
11447 | active[j] = false; | ||
11448 | } | 12543 | } |
11449 | else | 12544 | else if (index < earliestSrc) |
11450 | { | 12545 | { |
11451 | // present and correct | 12546 | earliestSrc = index; // where delimeter starts in source string |
11452 | if (offset[j] < offset[best]) | 12547 | earliestDel = j; // where delimeter is in delarray[] |
11453 | { | 12548 | earliestStr = d; // the delimeter string from delarray[] |
11454 | // closest so far | 12549 | if (index == i) break; // can't do any better than found at beg of string |
11455 | best = j; | ||
11456 | if (offset[best] == beginning) | ||
11457 | break; | ||
11458 | } | ||
11459 | } | 12550 | } |
11460 | } | 12551 | } |
11461 | } | 12552 | } |
11462 | 12553 | ||
11463 | // Scan for spacers | 12554 | /* |
11464 | 12555 | * Output source string starting at i through start of earliest delimeter. | |
11465 | if (offset[best] != beginning) | 12556 | */ |
12557 | if (keepNulls || (earliestSrc > i)) | ||
11466 | { | 12558 | { |
11467 | for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) | 12559 | outarray[outlen++] = src.Substring(i, earliestSrc - i); |
11468 | { | ||
11469 | if (spcarray[j-seplen].ToString() == String.Empty) | ||
11470 | active[j] = false; | ||
11471 | |||
11472 | if (active[j]) | ||
11473 | { | ||
11474 | // scan all of the markers | ||
11475 | if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) | ||
11476 | { | ||
11477 | // not present at all | ||
11478 | active[j] = false; | ||
11479 | } | ||
11480 | else | ||
11481 | { | ||
11482 | // present and correct | ||
11483 | if (offset[j] < offset[best]) | ||
11484 | { | ||
11485 | // closest so far | ||
11486 | best = j; | ||
11487 | } | ||
11488 | } | ||
11489 | } | ||
11490 | } | ||
11491 | } | 12560 | } |
11492 | 12561 | ||
11493 | // This is the normal exit from the scanning loop | 12562 | /* |
12563 | * If no delimeter found at or after i, we're done scanning. | ||
12564 | */ | ||
12565 | if (earliestDel < 0) break; | ||
11494 | 12566 | ||
11495 | if (best == mlen) | 12567 | /* |
12568 | * If delimeter was a spacer, output the spacer. | ||
12569 | */ | ||
12570 | if (earliestDel >= seplen) | ||
11496 | { | 12571 | { |
11497 | // no markers were found on this pass | 12572 | outarray[outlen++] = earliestStr; |
11498 | // so we're pretty much done | ||
11499 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) | ||
11500 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
11501 | break; | ||
11502 | } | 12573 | } |
11503 | 12574 | ||
11504 | // Otherwise we just add the newly delimited token | 12575 | /* |
11505 | // and recalculate where the search should continue. | 12576 | * Look at rest of src string following delimeter. |
11506 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | 12577 | */ |
11507 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 12578 | i = earliestSrc + earliestStr.Length; |
11508 | |||
11509 | if (best < seplen) | ||
11510 | { | ||
11511 | beginning = offset[best] + (separray[best].ToString()).Length; | ||
11512 | } | ||
11513 | else | ||
11514 | { | ||
11515 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | ||
11516 | string str = spcarray[best - seplen].ToString(); | ||
11517 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
11518 | tokens.Add(new LSL_String(str)); | ||
11519 | } | ||
11520 | } | 12579 | } |
11521 | 12580 | ||
11522 | // This an awkward an not very intuitive boundary case. If the | 12581 | /* |
11523 | // last substring is a tokenizer, then there is an implied trailing | 12582 | * Make up an exact-sized output array suitable for an LSL_List object. |
11524 | // null list entry. Hopefully the single comparison will not be too | 12583 | */ |
11525 | // arduous. Alternatively the 'break' could be replced with a return | 12584 | object[] outlist = new object[outlen]; |
11526 | // but that's shabby programming. | 12585 | for (i = 0; i < outlen; i ++) |
11527 | |||
11528 | if ((beginning == srclen) && (keepNulls)) | ||
11529 | { | 12586 | { |
11530 | if (srclen != 0) | 12587 | outlist[i] = new LSL_String(outarray[i]); |
11531 | tokens.Add(new LSL_String("")); | ||
11532 | } | 12588 | } |
11533 | 12589 | return new LSL_List(outlist); | |
11534 | return tokens; | ||
11535 | } | ||
11536 | |||
11537 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
11538 | { | ||
11539 | m_host.AddScriptLPS(1); | ||
11540 | return this.ParseString(src, separators, spacers, false); | ||
11541 | } | ||
11542 | |||
11543 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
11544 | { | ||
11545 | m_host.AddScriptLPS(1); | ||
11546 | return this.ParseString(src, separators, spacers, true); | ||
11547 | } | 12590 | } |
11548 | 12591 | ||
11549 | public LSL_Integer llGetObjectPermMask(int mask) | 12592 | public LSL_Integer llGetObjectPermMask(int mask) |
@@ -11841,31 +12884,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11841 | UUID key = new UUID(); | 12884 | UUID key = new UUID(); |
11842 | if (UUID.TryParse(id, out key)) | 12885 | if (UUID.TryParse(id, out key)) |
11843 | { | 12886 | { |
11844 | try | 12887 | // return total object mass |
11845 | { | 12888 | SceneObjectPart part = World.GetSceneObjectPart(key); |
11846 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); | 12889 | if (part != null) |
11847 | if (obj != null) | 12890 | return part.ParentGroup.GetMass(); |
11848 | return (double)obj.GetMass(); | 12891 | |
11849 | // the object is null so the key is for an avatar | 12892 | // the object is null so the key is for an avatar |
11850 | ScenePresence avatar = World.GetScenePresence(key); | 12893 | ScenePresence avatar = World.GetScenePresence(key); |
11851 | if (avatar != null) | 12894 | if (avatar != null) |
11852 | if (avatar.IsChildAgent) | ||
11853 | // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass | ||
11854 | // child agents have a mass of 1.0 | ||
11855 | return 1; | ||
11856 | else | ||
11857 | return (double)avatar.GetMass(); | ||
11858 | } | ||
11859 | catch (KeyNotFoundException) | ||
11860 | { | 12895 | { |
11861 | return 0; // The Object/Agent not in the region so just return zero | 12896 | if (avatar.IsChildAgent) |
12897 | { | ||
12898 | // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass | ||
12899 | // child agents have a mass of 1.0 | ||
12900 | return 1; | ||
12901 | } | ||
12902 | else | ||
12903 | { | ||
12904 | return (double)avatar.GetMass(); | ||
12905 | } | ||
11862 | } | 12906 | } |
11863 | } | 12907 | } |
11864 | return 0; | 12908 | return 0; |
11865 | } | 12909 | } |
11866 | 12910 | ||
11867 | /// <summary> | 12911 | /// <summary> |
11868 | /// illListReplaceList removes the sub-list defined by the inclusive indices | 12912 | /// llListReplaceList removes the sub-list defined by the inclusive indices |
11869 | /// start and end and inserts the src list in its place. The inclusive | 12913 | /// start and end and inserts the src list in its place. The inclusive |
11870 | /// nature of the indices means that at least one element must be deleted | 12914 | /// nature of the indices means that at least one element must be deleted |
11871 | /// if the indices are within the bounds of the existing list. I.e. 2,2 | 12915 | /// if the indices are within the bounds of the existing list. I.e. 2,2 |
@@ -11922,16 +12966,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11922 | // based upon end. Note that if end exceeds the upper | 12966 | // based upon end. Note that if end exceeds the upper |
11923 | // bound in this case, the entire destination list | 12967 | // bound in this case, the entire destination list |
11924 | // is removed. | 12968 | // is removed. |
11925 | else | 12969 | else if (start == 0) |
11926 | { | 12970 | { |
11927 | if (end + 1 < dest.Length) | 12971 | if (end + 1 < dest.Length) |
11928 | { | ||
11929 | return src + dest.GetSublist(end + 1, -1); | 12972 | return src + dest.GetSublist(end + 1, -1); |
11930 | } | ||
11931 | else | 12973 | else |
11932 | { | ||
11933 | return src; | 12974 | return src; |
11934 | } | 12975 | } |
12976 | else // Start < 0 | ||
12977 | { | ||
12978 | if (end + 1 < dest.Length) | ||
12979 | return dest.GetSublist(end + 1, -1); | ||
12980 | else | ||
12981 | return new LSL_List(); | ||
11935 | } | 12982 | } |
11936 | } | 12983 | } |
11937 | // Finally, if start > end, we strip away a prefix and | 12984 | // Finally, if start > end, we strip away a prefix and |
@@ -11968,7 +13015,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11968 | // according to the docs, this command only works if script owner and land owner are the same | 13015 | // according to the docs, this command only works if script owner and land owner are the same |
11969 | // lets add estate owners and gods, too, and use the generic permission check. | 13016 | // lets add estate owners and gods, too, and use the generic permission check. |
11970 | ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition); | 13017 | ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
11971 | if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return; | 13018 | if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia, false)) return; |
11972 | 13019 | ||
11973 | bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)? | 13020 | bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)? |
11974 | byte loop = 0; | 13021 | byte loop = 0; |
@@ -11982,17 +13029,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11982 | int width = 0; | 13029 | int width = 0; |
11983 | int height = 0; | 13030 | int height = 0; |
11984 | 13031 | ||
11985 | ParcelMediaCommandEnum? commandToSend = null; | 13032 | uint commandToSend = 0; |
11986 | float time = 0.0f; // default is from start | 13033 | float time = 0.0f; // default is from start |
11987 | 13034 | ||
11988 | ScenePresence presence = null; | 13035 | ScenePresence presence = null; |
11989 | 13036 | ||
11990 | for (int i = 0; i < commandList.Data.Length; i++) | 13037 | for (int i = 0; i < commandList.Data.Length; i++) |
11991 | { | 13038 | { |
11992 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 13039 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
11993 | switch (command) | 13040 | switch (command) |
11994 | { | 13041 | { |
11995 | case ParcelMediaCommandEnum.Agent: | 13042 | case (uint)ParcelMediaCommandEnum.Agent: |
11996 | // we send only to one agent | 13043 | // we send only to one agent |
11997 | if ((i + 1) < commandList.Length) | 13044 | if ((i + 1) < commandList.Length) |
11998 | { | 13045 | { |
@@ -12009,25 +13056,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12009 | } | 13056 | } |
12010 | break; | 13057 | break; |
12011 | 13058 | ||
12012 | case ParcelMediaCommandEnum.Loop: | 13059 | case (uint)ParcelMediaCommandEnum.Loop: |
12013 | loop = 1; | 13060 | loop = 1; |
12014 | commandToSend = command; | 13061 | commandToSend = command; |
12015 | update = true; //need to send the media update packet to set looping | 13062 | update = true; //need to send the media update packet to set looping |
12016 | break; | 13063 | break; |
12017 | 13064 | ||
12018 | case ParcelMediaCommandEnum.Play: | 13065 | case (uint)ParcelMediaCommandEnum.Play: |
12019 | loop = 0; | 13066 | loop = 0; |
12020 | commandToSend = command; | 13067 | commandToSend = command; |
12021 | update = true; //need to send the media update packet to make sure it doesn't loop | 13068 | update = true; //need to send the media update packet to make sure it doesn't loop |
12022 | break; | 13069 | break; |
12023 | 13070 | ||
12024 | case ParcelMediaCommandEnum.Pause: | 13071 | case (uint)ParcelMediaCommandEnum.Pause: |
12025 | case ParcelMediaCommandEnum.Stop: | 13072 | case (uint)ParcelMediaCommandEnum.Stop: |
12026 | case ParcelMediaCommandEnum.Unload: | 13073 | case (uint)ParcelMediaCommandEnum.Unload: |
12027 | commandToSend = command; | 13074 | commandToSend = command; |
12028 | break; | 13075 | break; |
12029 | 13076 | ||
12030 | case ParcelMediaCommandEnum.Url: | 13077 | case (uint)ParcelMediaCommandEnum.Url: |
12031 | if ((i + 1) < commandList.Length) | 13078 | if ((i + 1) < commandList.Length) |
12032 | { | 13079 | { |
12033 | if (commandList.Data[i + 1] is LSL_String) | 13080 | if (commandList.Data[i + 1] is LSL_String) |
@@ -12040,7 +13087,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12040 | } | 13087 | } |
12041 | break; | 13088 | break; |
12042 | 13089 | ||
12043 | case ParcelMediaCommandEnum.Texture: | 13090 | case (uint)ParcelMediaCommandEnum.Texture: |
12044 | if ((i + 1) < commandList.Length) | 13091 | if ((i + 1) < commandList.Length) |
12045 | { | 13092 | { |
12046 | if (commandList.Data[i + 1] is LSL_String) | 13093 | if (commandList.Data[i + 1] is LSL_String) |
@@ -12053,7 +13100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12053 | } | 13100 | } |
12054 | break; | 13101 | break; |
12055 | 13102 | ||
12056 | case ParcelMediaCommandEnum.Time: | 13103 | case (uint)ParcelMediaCommandEnum.Time: |
12057 | if ((i + 1) < commandList.Length) | 13104 | if ((i + 1) < commandList.Length) |
12058 | { | 13105 | { |
12059 | if (commandList.Data[i + 1] is LSL_Float) | 13106 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -12065,7 +13112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12065 | } | 13112 | } |
12066 | break; | 13113 | break; |
12067 | 13114 | ||
12068 | case ParcelMediaCommandEnum.AutoAlign: | 13115 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
12069 | if ((i + 1) < commandList.Length) | 13116 | if ((i + 1) < commandList.Length) |
12070 | { | 13117 | { |
12071 | if (commandList.Data[i + 1] is LSL_Integer) | 13118 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -12079,7 +13126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12079 | } | 13126 | } |
12080 | break; | 13127 | break; |
12081 | 13128 | ||
12082 | case ParcelMediaCommandEnum.Type: | 13129 | case (uint)ParcelMediaCommandEnum.Type: |
12083 | if ((i + 1) < commandList.Length) | 13130 | if ((i + 1) < commandList.Length) |
12084 | { | 13131 | { |
12085 | if (commandList.Data[i + 1] is LSL_String) | 13132 | if (commandList.Data[i + 1] is LSL_String) |
@@ -12092,7 +13139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12092 | } | 13139 | } |
12093 | break; | 13140 | break; |
12094 | 13141 | ||
12095 | case ParcelMediaCommandEnum.Desc: | 13142 | case (uint)ParcelMediaCommandEnum.Desc: |
12096 | if ((i + 1) < commandList.Length) | 13143 | if ((i + 1) < commandList.Length) |
12097 | { | 13144 | { |
12098 | if (commandList.Data[i + 1] is LSL_String) | 13145 | if (commandList.Data[i + 1] is LSL_String) |
@@ -12105,7 +13152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12105 | } | 13152 | } |
12106 | break; | 13153 | break; |
12107 | 13154 | ||
12108 | case ParcelMediaCommandEnum.Size: | 13155 | case (uint)ParcelMediaCommandEnum.Size: |
12109 | if ((i + 2) < commandList.Length) | 13156 | if ((i + 2) < commandList.Length) |
12110 | { | 13157 | { |
12111 | if (commandList.Data[i + 1] is LSL_Integer) | 13158 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -12175,7 +13222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12175 | } | 13222 | } |
12176 | } | 13223 | } |
12177 | 13224 | ||
12178 | if (commandToSend != null) | 13225 | if (commandToSend != 0) |
12179 | { | 13226 | { |
12180 | // the commandList contained a start/stop/... command, too | 13227 | // the commandList contained a start/stop/... command, too |
12181 | if (presence == null) | 13228 | if (presence == null) |
@@ -12212,7 +13259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12212 | 13259 | ||
12213 | if (aList.Data[i] != null) | 13260 | if (aList.Data[i] != null) |
12214 | { | 13261 | { |
12215 | switch ((ParcelMediaCommandEnum) aList.Data[i]) | 13262 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
12216 | { | 13263 | { |
12217 | case ParcelMediaCommandEnum.Url: | 13264 | case ParcelMediaCommandEnum.Url: |
12218 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL)); | 13265 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL)); |
@@ -12269,15 +13316,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12269 | 13316 | ||
12270 | if (quick_pay_buttons.Data.Length < 4) | 13317 | if (quick_pay_buttons.Data.Length < 4) |
12271 | { | 13318 | { |
13319 | <<<<<<< HEAD | ||
12272 | Error("llSetPayPrice", "List must have at least 4 elements"); | 13320 | Error("llSetPayPrice", "List must have at least 4 elements"); |
12273 | return; | 13321 | return; |
12274 | } | 13322 | ======= |
12275 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 13323 | int x; |
12276 | 13324 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) | |
12277 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 13325 | { |
12278 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 13326 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); |
12279 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 13327 | } |
12280 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 13328 | >>>>>>> avn/ubitvar |
13329 | } | ||
13330 | int[] nPrice = new int[5]; | ||
13331 | nPrice[0] = price; | ||
13332 | nPrice[1] = quick_pay_buttons.GetLSLIntegerItem(0); | ||
13333 | nPrice[2] = quick_pay_buttons.GetLSLIntegerItem(1); | ||
13334 | nPrice[3] = quick_pay_buttons.GetLSLIntegerItem(2); | ||
13335 | nPrice[4] = quick_pay_buttons.GetLSLIntegerItem(3); | ||
13336 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
12281 | m_host.ParentGroup.HasGroupChanged = true; | 13337 | m_host.ParentGroup.HasGroupChanged = true; |
12282 | } | 13338 | } |
12283 | 13339 | ||
@@ -12294,7 +13350,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12294 | return Vector3.Zero; | 13350 | return Vector3.Zero; |
12295 | } | 13351 | } |
12296 | 13352 | ||
12297 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 13353 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
13354 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
12298 | if (presence != null) | 13355 | if (presence != null) |
12299 | { | 13356 | { |
12300 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition); | 13357 | LSL_Vector pos = new LSL_Vector(presence.CameraPosition); |
@@ -12317,7 +13374,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12317 | return Quaternion.Identity; | 13374 | return Quaternion.Identity; |
12318 | } | 13375 | } |
12319 | 13376 | ||
12320 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 13377 | // ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
13378 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
12321 | if (presence != null) | 13379 | if (presence != null) |
12322 | { | 13380 | { |
12323 | return new LSL_Rotation(presence.CameraRotation); | 13381 | return new LSL_Rotation(presence.CameraRotation); |
@@ -12370,15 +13428,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12370 | { | 13428 | { |
12371 | m_host.AddScriptLPS(1); | 13429 | m_host.AddScriptLPS(1); |
12372 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); | 13430 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); |
12373 | if (detectedParams == null) return; // only works on the first detected avatar | 13431 | if (detectedParams == null) |
12374 | 13432 | { | |
13433 | if (m_host.ParentGroup.IsAttachment == true) | ||
13434 | { | ||
13435 | detectedParams = new DetectParams(); | ||
13436 | detectedParams.Key = m_host.OwnerID; | ||
13437 | } | ||
13438 | else | ||
13439 | { | ||
13440 | return; | ||
13441 | } | ||
13442 | } | ||
13443 | |||
12375 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 13444 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
12376 | if (avatar != null) | 13445 | if (avatar != null) |
12377 | { | 13446 | { |
12378 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, | 13447 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, |
12379 | simname, pos, lookAt); | 13448 | simname, pos, lookAt); |
12380 | } | 13449 | } |
13450 | <<<<<<< HEAD | ||
12381 | ScriptSleep(m_sleepMsOnMapDestination); | 13451 | ScriptSleep(m_sleepMsOnMapDestination); |
13452 | ======= | ||
13453 | |||
13454 | ScriptSleep(1000); | ||
13455 | >>>>>>> avn/ubitvar | ||
12382 | } | 13456 | } |
12383 | 13457 | ||
12384 | public void llAddToLandBanList(string avatar, double hours) | 13458 | public void llAddToLandBanList(string avatar, double hours) |
@@ -12386,7 +13460,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12386 | m_host.AddScriptLPS(1); | 13460 | m_host.AddScriptLPS(1); |
12387 | UUID key; | 13461 | UUID key; |
12388 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); | 13462 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
12389 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) | 13463 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) |
12390 | { | 13464 | { |
12391 | int expires = 0; | 13465 | int expires = 0; |
12392 | if (hours != 0) | 13466 | if (hours != 0) |
@@ -12427,7 +13501,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12427 | m_host.AddScriptLPS(1); | 13501 | m_host.AddScriptLPS(1); |
12428 | UUID key; | 13502 | UUID key; |
12429 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); | 13503 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
12430 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) | 13504 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed, false)) |
12431 | { | 13505 | { |
12432 | if (UUID.TryParse(avatar, out key)) | 13506 | if (UUID.TryParse(avatar, out key)) |
12433 | { | 13507 | { |
@@ -12454,7 +13528,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12454 | m_host.AddScriptLPS(1); | 13528 | m_host.AddScriptLPS(1); |
12455 | UUID key; | 13529 | UUID key; |
12456 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); | 13530 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition); |
12457 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) | 13531 | if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned, false)) |
12458 | { | 13532 | { |
12459 | if (UUID.TryParse(avatar, out key)) | 13533 | if (UUID.TryParse(avatar, out key)) |
12460 | { | 13534 | { |
@@ -12503,6 +13577,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12503 | object[] data = rules.Data; | 13577 | object[] data = rules.Data; |
12504 | for (int i = 0; i < data.Length; ++i) | 13578 | for (int i = 0; i < data.Length; ++i) |
12505 | { | 13579 | { |
13580 | <<<<<<< HEAD | ||
12506 | int type; | 13581 | int type; |
12507 | try | 13582 | try |
12508 | { | 13583 | { |
@@ -12513,6 +13588,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12513 | Error("llSetCameraParams", string.Format("Invalid camera param type {0}", data[i - 1])); | 13588 | Error("llSetCameraParams", string.Format("Invalid camera param type {0}", data[i - 1])); |
12514 | return; | 13589 | return; |
12515 | } | 13590 | } |
13591 | ======= | ||
13592 | int type = Convert.ToInt32(data[i++].ToString()); | ||
13593 | >>>>>>> avn/ubitvar | ||
12516 | if (i >= data.Length) break; // odd number of entries => ignore the last | 13594 | if (i >= data.Length) break; // odd number of entries => ignore the last |
12517 | 13595 | ||
12518 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) | 13596 | // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) |
@@ -12686,19 +13764,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12686 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) | 13764 | public LSL_String llXorBase64StringsCorrect(string str1, string str2) |
12687 | { | 13765 | { |
12688 | m_host.AddScriptLPS(1); | 13766 | m_host.AddScriptLPS(1); |
12689 | string ret = String.Empty; | 13767 | |
12690 | string src1 = llBase64ToString(str1); | 13768 | if (str1 == String.Empty) |
12691 | string src2 = llBase64ToString(str2); | 13769 | return String.Empty; |
12692 | int c = 0; | 13770 | if (str2 == String.Empty) |
12693 | for (int i = 0; i < src1.Length; i++) | 13771 | return str1; |
13772 | |||
13773 | int len = str2.Length; | ||
13774 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
13775 | { | ||
13776 | while (str2.EndsWith("=")) | ||
13777 | str2 = str2.Substring(0, str2.Length - 1); | ||
13778 | |||
13779 | len = str2.Length; | ||
13780 | int mod = len % 4; | ||
13781 | |||
13782 | if (mod == 1) | ||
13783 | str2 = str2.Substring(0, str2.Length - 1); | ||
13784 | else if (mod == 2) | ||
13785 | str2 += "=="; | ||
13786 | else if (mod == 3) | ||
13787 | str2 += "="; | ||
13788 | } | ||
13789 | |||
13790 | byte[] data1; | ||
13791 | byte[] data2; | ||
13792 | try | ||
13793 | { | ||
13794 | data1 = Convert.FromBase64String(str1); | ||
13795 | data2 = Convert.FromBase64String(str2); | ||
13796 | } | ||
13797 | catch (Exception) | ||
13798 | { | ||
13799 | return new LSL_String(String.Empty); | ||
13800 | } | ||
13801 | |||
13802 | byte[] d2 = new Byte[data1.Length]; | ||
13803 | int pos = 0; | ||
13804 | |||
13805 | if (data1.Length <= data2.Length) | ||
12694 | { | 13806 | { |
12695 | ret += (char) (src1[i] ^ src2[c]); | 13807 | Array.Copy(data2, 0, d2, 0, data1.Length); |
13808 | } | ||
13809 | else | ||
13810 | { | ||
13811 | while (pos < data1.Length) | ||
13812 | { | ||
13813 | len = data1.Length - pos; | ||
13814 | if (len > data2.Length) | ||
13815 | len = data2.Length; | ||
12696 | 13816 | ||
12697 | c++; | 13817 | Array.Copy(data2, 0, d2, pos, len); |
12698 | if (c >= src2.Length) | 13818 | pos += len; |
12699 | c = 0; | 13819 | } |
12700 | } | 13820 | } |
12701 | return llStringToBase64(ret); | 13821 | |
13822 | for (pos = 0 ; pos < data1.Length ; pos++ ) | ||
13823 | data1[pos] ^= d2[pos]; | ||
13824 | |||
13825 | return Convert.ToBase64String(data1); | ||
12702 | } | 13826 | } |
12703 | 13827 | ||
12704 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) | 13828 | public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) |
@@ -12802,16 +13926,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12802 | if (userAgent != null) | 13926 | if (userAgent != null) |
12803 | httpHeaders["User-Agent"] = userAgent; | 13927 | httpHeaders["User-Agent"] = userAgent; |
12804 | 13928 | ||
13929 | // See if the URL contains any header hacks | ||
13930 | string[] urlParts = url.Split(new char[] {'\n'}); | ||
13931 | if (urlParts.Length > 1) | ||
13932 | { | ||
13933 | // Iterate the passed headers and parse them | ||
13934 | for (int i = 1 ; i < urlParts.Length ; i++ ) | ||
13935 | { | ||
13936 | // The rest of those would be added to the body in SL. | ||
13937 | // Let's not do that. | ||
13938 | if (urlParts[i] == String.Empty) | ||
13939 | break; | ||
13940 | |||
13941 | // See if this could be a valid header | ||
13942 | string[] headerParts = urlParts[i].Split(new char[] {':'}, 2); | ||
13943 | if (headerParts.Length != 2) | ||
13944 | continue; | ||
13945 | |||
13946 | string headerName = headerParts[0].Trim(); | ||
13947 | string headerValue = headerParts[1].Trim(); | ||
13948 | |||
13949 | // Filter out headers that could be used to abuse | ||
13950 | // another system or cloak the request | ||
13951 | if (headerName.ToLower() == "x-secondlife-shard" || | ||
13952 | headerName.ToLower() == "x-secondlife-object-name" || | ||
13953 | headerName.ToLower() == "x-secondlife-object-key" || | ||
13954 | headerName.ToLower() == "x-secondlife-region" || | ||
13955 | headerName.ToLower() == "x-secondlife-local-position" || | ||
13956 | headerName.ToLower() == "x-secondlife-local-velocity" || | ||
13957 | headerName.ToLower() == "x-secondlife-local-rotation" || | ||
13958 | headerName.ToLower() == "x-secondlife-owner-name" || | ||
13959 | headerName.ToLower() == "x-secondlife-owner-key" || | ||
13960 | headerName.ToLower() == "connection" || | ||
13961 | headerName.ToLower() == "content-length" || | ||
13962 | headerName.ToLower() == "from" || | ||
13963 | headerName.ToLower() == "host" || | ||
13964 | headerName.ToLower() == "proxy-authorization" || | ||
13965 | headerName.ToLower() == "referer" || | ||
13966 | headerName.ToLower() == "trailer" || | ||
13967 | headerName.ToLower() == "transfer-encoding" || | ||
13968 | headerName.ToLower() == "via" || | ||
13969 | headerName.ToLower() == "authorization") | ||
13970 | continue; | ||
13971 | |||
13972 | httpHeaders[headerName] = headerValue; | ||
13973 | } | ||
13974 | |||
13975 | // Finally, strip any protocol specifier from the URL | ||
13976 | url = urlParts[0].Trim(); | ||
13977 | int idx = url.IndexOf(" HTTP/"); | ||
13978 | if (idx != -1) | ||
13979 | url = url.Substring(0, idx); | ||
13980 | } | ||
13981 | |||
12805 | string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; | 13982 | string authregex = @"^(https?:\/\/)(\w+):(\w+)@(.*)$"; |
12806 | Regex r = new Regex(authregex); | 13983 | Regex r = new Regex(authregex); |
12807 | int[] gnums = r.GetGroupNumbers(); | 13984 | int[] gnums = r.GetGroupNumbers(); |
12808 | Match m = r.Match(url); | 13985 | Match m = r.Match(url); |
12809 | if (m.Success) { | 13986 | if (m.Success) |
12810 | for (int i = 1; i < gnums.Length; i++) { | 13987 | { |
13988 | for (int i = 1; i < gnums.Length; i++) | ||
13989 | { | ||
12811 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; | 13990 | //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; |
12812 | //CaptureCollection cc = g.Captures; | 13991 | //CaptureCollection cc = g.Captures; |
12813 | } | 13992 | } |
12814 | if (m.Groups.Count == 5) { | 13993 | if (m.Groups.Count == 5) |
13994 | { | ||
12815 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); | 13995 | httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); |
12816 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); | 13996 | url = m.Groups[1].ToString() + m.Groups[4].ToString(); |
12817 | } | 13997 | } |
@@ -13018,6 +14198,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13018 | 14198 | ||
13019 | LSL_List ret = new LSL_List(); | 14199 | LSL_List ret = new LSL_List(); |
13020 | UUID key = new UUID(); | 14200 | UUID key = new UUID(); |
14201 | |||
14202 | |||
13021 | if (UUID.TryParse(id, out key)) | 14203 | if (UUID.TryParse(id, out key)) |
13022 | { | 14204 | { |
13023 | ScenePresence av = World.GetScenePresence(key); | 14205 | ScenePresence av = World.GetScenePresence(key); |
@@ -13035,13 +14217,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13035 | ret.Add(new LSL_String("")); | 14217 | ret.Add(new LSL_String("")); |
13036 | break; | 14218 | break; |
13037 | case ScriptBaseClass.OBJECT_POS: | 14219 | case ScriptBaseClass.OBJECT_POS: |
13038 | ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); | 14220 | Vector3 avpos; |
14221 | |||
14222 | if (av.ParentID != 0 && av.ParentPart != null) | ||
14223 | { | ||
14224 | avpos = av.OffsetPosition; | ||
14225 | |||
14226 | Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
14227 | avpos -= sitOffset; | ||
14228 | |||
14229 | avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation(); | ||
14230 | } | ||
14231 | else | ||
14232 | avpos = av.AbsolutePosition; | ||
14233 | |||
14234 | ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); | ||
13039 | break; | 14235 | break; |
13040 | case ScriptBaseClass.OBJECT_ROT: | 14236 | case ScriptBaseClass.OBJECT_ROT: |
13041 | ret.Add(new LSL_Rotation(av.GetWorldRotation())); | 14237 | Quaternion avrot = av.Rotation; |
14238 | if (av.ParentID != 0 && av.ParentPart != null) | ||
14239 | { | ||
14240 | avrot = av.ParentPart.GetWorldRotation() * avrot; | ||
14241 | } | ||
14242 | ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W)); | ||
13042 | break; | 14243 | break; |
13043 | case ScriptBaseClass.OBJECT_VELOCITY: | 14244 | case ScriptBaseClass.OBJECT_VELOCITY: |
14245 | <<<<<<< HEAD | ||
13044 | ret.Add(new LSL_Vector(av.GetWorldVelocity())); | 14246 | ret.Add(new LSL_Vector(av.GetWorldVelocity())); |
14247 | ======= | ||
14248 | Vector3 avvel = av.Velocity; | ||
14249 | ret.Add(new LSL_Vector((double)avvel.X, (double)avvel.Y, (double)avvel.Z)); | ||
14250 | >>>>>>> avn/ubitvar | ||
13045 | break; | 14251 | break; |
13046 | case ScriptBaseClass.OBJECT_OWNER: | 14252 | case ScriptBaseClass.OBJECT_OWNER: |
13047 | ret.Add(new LSL_String(id)); | 14253 | ret.Add(new LSL_String(id)); |
@@ -13143,11 +14349,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13143 | case ScriptBaseClass.OBJECT_NAME: | 14349 | case ScriptBaseClass.OBJECT_NAME: |
13144 | ret.Add(new LSL_String(obj.Name)); | 14350 | ret.Add(new LSL_String(obj.Name)); |
13145 | break; | 14351 | break; |
13146 | case ScriptBaseClass.OBJECT_DESC: | 14352 | case ScriptBaseClass.OBJECT_DESC: |
13147 | ret.Add(new LSL_String(obj.Description)); | 14353 | ret.Add(new LSL_String(obj.Description)); |
13148 | break; | 14354 | break; |
13149 | case ScriptBaseClass.OBJECT_POS: | 14355 | case ScriptBaseClass.OBJECT_POS: |
13150 | ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); | 14356 | Vector3 opos = obj.AbsolutePosition; |
14357 | ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); | ||
13151 | break; | 14358 | break; |
13152 | case ScriptBaseClass.OBJECT_ROT: | 14359 | case ScriptBaseClass.OBJECT_ROT: |
13153 | Quaternion rot = Quaternion.Identity; | 14360 | Quaternion rot = Quaternion.Identity; |
@@ -13220,9 +14427,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13220 | // The value returned in SL for normal prims is prim count | 14427 | // The value returned in SL for normal prims is prim count |
13221 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); | 14428 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
13222 | break; | 14429 | break; |
13223 | // The following 3 costs I have intentionaly coded to return zero. They are part of | 14430 | |
13224 | // "Land Impact" calculations. These calculations are probably not applicable | 14431 | // costs below may need to be diferent for root parts, need to check |
13225 | // to OpenSim and are not yet complete in SL | ||
13226 | case ScriptBaseClass.OBJECT_SERVER_COST: | 14432 | case ScriptBaseClass.OBJECT_SERVER_COST: |
13227 | // The linden calculation is here | 14433 | // The linden calculation is here |
13228 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | 14434 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight |
@@ -13230,16 +14436,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13230 | ret.Add(new LSL_Float(0)); | 14436 | ret.Add(new LSL_Float(0)); |
13231 | break; | 14437 | break; |
13232 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 14438 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
13233 | // The linden calculation is here | 14439 | // The value returned in SL for normal prims is prim count * 0.06 |
13234 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | 14440 | ret.Add(new LSL_Float(obj.StreamingCost)); |
13235 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
13236 | ret.Add(new LSL_Float(0)); | ||
13237 | break; | 14441 | break; |
13238 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 14442 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
13239 | // The linden calculation is here | 14443 | // The value returned in SL for normal prims is prim count |
13240 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | 14444 | ret.Add(new LSL_Float(obj.PhysicsCost)); |
13241 | // The value returned in SL for normal prims looks like the prim count | ||
13242 | ret.Add(new LSL_Float(0)); | ||
13243 | break; | 14445 | break; |
13244 | case ScriptBaseClass.OBJECT_CHARACTER_TIME: // Pathfinding | 14446 | case ScriptBaseClass.OBJECT_CHARACTER_TIME: // Pathfinding |
13245 | ret.Add(new LSL_Float(0)); | 14447 | ret.Add(new LSL_Float(0)); |
@@ -13530,15 +14732,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13530 | return new LSL_List(); | 14732 | return new LSL_List(); |
13531 | } | 14733 | } |
13532 | 14734 | ||
13533 | public void print(string str) | 14735 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
13534 | { | 14736 | { |
13535 | // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print | 14737 | List<SceneObjectPart> parts = GetLinkParts(link); |
13536 | IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); | 14738 | if (parts.Count < 1) |
13537 | if (ossl != null) | 14739 | return 0; |
13538 | { | 14740 | |
13539 | ossl.CheckThreatLevel(ThreatLevel.High, "print"); | 14741 | return GetNumberOfSides(parts[0]); |
13540 | m_log.Info("LSL print():" + str); | ||
13541 | } | ||
13542 | } | 14742 | } |
13543 | 14743 | ||
13544 | private string Name2Username(string name) | 14744 | private string Name2Username(string name) |
@@ -13583,7 +14783,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13583 | 14783 | ||
13584 | return rq.ToString(); | 14784 | return rq.ToString(); |
13585 | } | 14785 | } |
13586 | 14786 | /* | |
14787 | private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) | ||
14788 | { | ||
14789 | m_SayShoutCount = 0; | ||
14790 | } | ||
14791 | */ | ||
13587 | private struct Tri | 14792 | private struct Tri |
13588 | { | 14793 | { |
13589 | public Vector3 p1; | 14794 | public Vector3 p1; |
@@ -13732,9 +14937,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13732 | 14937 | ||
13733 | ContactResult result = new ContactResult (); | 14938 | ContactResult result = new ContactResult (); |
13734 | result.ConsumerID = group.LocalId; | 14939 | result.ConsumerID = group.LocalId; |
13735 | result.Depth = intersection.distance; | 14940 | // result.Depth = intersection.distance; |
13736 | result.Normal = intersection.normal; | 14941 | result.Normal = intersection.normal; |
13737 | result.Pos = intersection.ipoint; | 14942 | result.Pos = intersection.ipoint; |
14943 | result.Depth = Vector3.Mag(rayStart - result.Pos); | ||
13738 | 14944 | ||
13739 | contacts.Add(result); | 14945 | contacts.Add(result); |
13740 | }); | 14946 | }); |
@@ -13867,6 +15073,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13867 | 15073 | ||
13868 | return contacts[0]; | 15074 | return contacts[0]; |
13869 | } | 15075 | } |
15076 | /* | ||
15077 | // not done: | ||
15078 | private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght) | ||
15079 | { | ||
15080 | ContactResult[] contacts = null; | ||
15081 | World.ForEachSOG(delegate(SceneObjectGroup group) | ||
15082 | { | ||
15083 | if (m_host.ParentGroup == group) | ||
15084 | return; | ||
15085 | |||
15086 | if (group.IsAttachment) | ||
15087 | return; | ||
15088 | |||
15089 | if(group.RootPart.PhysActor != null) | ||
15090 | return; | ||
15091 | |||
15092 | contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght); | ||
15093 | }); | ||
15094 | return contacts; | ||
15095 | } | ||
15096 | */ | ||
13870 | 15097 | ||
13871 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | 15098 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) |
13872 | { | 15099 | { |
@@ -13994,18 +15221,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13994 | } | 15221 | } |
13995 | } | 15222 | } |
13996 | 15223 | ||
15224 | // Double check this | ||
13997 | if (checkTerrain) | 15225 | if (checkTerrain) |
13998 | { | 15226 | { |
13999 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | 15227 | bool skipGroundCheck = false; |
14000 | if (groundContact != null) | 15228 | |
14001 | results.Add((ContactResult)groundContact); | 15229 | foreach (ContactResult c in results) |
15230 | { | ||
15231 | if (c.ConsumerID == 0) // Physics gave us a ground collision | ||
15232 | skipGroundCheck = true; | ||
15233 | } | ||
15234 | |||
15235 | if (!skipGroundCheck) | ||
15236 | { | ||
15237 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | ||
15238 | if (groundContact != null) | ||
15239 | results.Add((ContactResult)groundContact); | ||
15240 | } | ||
14002 | } | 15241 | } |
14003 | 15242 | ||
14004 | results.Sort(delegate(ContactResult a, ContactResult b) | 15243 | results.Sort(delegate(ContactResult a, ContactResult b) |
14005 | { | 15244 | { |
14006 | return a.Depth.CompareTo(b.Depth); | 15245 | return a.Depth.CompareTo(b.Depth); |
14007 | }); | 15246 | }); |
14008 | 15247 | ||
14009 | int values = 0; | 15248 | int values = 0; |
14010 | SceneObjectGroup thisgrp = m_host.ParentGroup; | 15249 | SceneObjectGroup thisgrp = m_host.ParentGroup; |
14011 | 15250 | ||
@@ -14964,7 +16203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14964 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: | 16203 | case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD: |
14965 | if (!isAccount) return 0; | 16204 | if (!isAccount) return 0; |
14966 | if (estate.HasAccess(id)) return 1; | 16205 | if (estate.HasAccess(id)) return 1; |
14967 | if (estate.IsBanned(id)) | 16206 | if (estate.IsBanned(id, World.GetUserFlags(id))) |
14968 | estate.RemoveBan(id); | 16207 | estate.RemoveBan(id); |
14969 | estate.AddEstateUser(id); | 16208 | estate.AddEstateUser(id); |
14970 | break; | 16209 | break; |
@@ -14983,14 +16222,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14983 | break; | 16222 | break; |
14984 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: | 16223 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD: |
14985 | if (!isAccount) return 0; | 16224 | if (!isAccount) return 0; |
14986 | if (estate.IsBanned(id)) return 1; | 16225 | if (estate.IsBanned(id, World.GetUserFlags(id))) return 1; |
14987 | EstateBan ban = new EstateBan(); | 16226 | EstateBan ban = new EstateBan(); |
14988 | ban.EstateID = estate.EstateID; | 16227 | ban.EstateID = estate.EstateID; |
14989 | ban.BannedUserID = id; | 16228 | ban.BannedUserID = id; |
14990 | estate.AddBan(ban); | 16229 | estate.AddBan(ban); |
14991 | break; | 16230 | break; |
14992 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: | 16231 | case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE: |
14993 | if (!isAccount || !estate.IsBanned(id)) return 0; | 16232 | if (!isAccount || !estate.IsBanned(id, World.GetUserFlags(id))) return 0; |
14994 | estate.RemoveBan(id); | 16233 | estate.RemoveBan(id); |
14995 | break; | 16234 | break; |
14996 | default: return 0; | 16235 | default: return 0; |
@@ -15049,13 +16288,63 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
15049 | public void llCollisionSprite(string impact_sprite) | 16288 | public void llCollisionSprite(string impact_sprite) |
15050 | { | 16289 | { |
15051 | m_host.AddScriptLPS(1); | 16290 | m_host.AddScriptLPS(1); |
15052 | NotImplemented("llCollisionSprite"); | 16291 | // Viewer 2.0 broke this and it's likely LL has no intention |
16292 | // of fixing it. Therefore, letting this be a NOP seems appropriate. | ||
15053 | } | 16293 | } |
15054 | 16294 | ||
15055 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) | 16295 | public void llGodLikeRezObject(string inventory, LSL_Vector pos) |
15056 | { | 16296 | { |
15057 | m_host.AddScriptLPS(1); | 16297 | m_host.AddScriptLPS(1); |
15058 | NotImplemented("llGodLikeRezObject"); | 16298 | |
16299 | if (!World.Permissions.IsGod(m_host.OwnerID)) | ||
16300 | NotImplemented("llGodLikeRezObject"); | ||
16301 | |||
16302 | AssetBase rezAsset = World.AssetService.Get(inventory); | ||
16303 | if (rezAsset == null) | ||
16304 | { | ||
16305 | llSay(0, "Asset not found"); | ||
16306 | return; | ||
16307 | } | ||
16308 | |||
16309 | SceneObjectGroup group = null; | ||
16310 | |||
16311 | try | ||
16312 | { | ||
16313 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
16314 | group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
16315 | } | ||
16316 | catch | ||
16317 | { | ||
16318 | llSay(0, "Asset not found"); | ||
16319 | return; | ||
16320 | } | ||
16321 | |||
16322 | if (group == null) | ||
16323 | { | ||
16324 | llSay(0, "Asset not found"); | ||
16325 | return; | ||
16326 | } | ||
16327 | |||
16328 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
16329 | group.RootPart.AttachedPos = group.AbsolutePosition; | ||
16330 | |||
16331 | group.ResetIDs(); | ||
16332 | |||
16333 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
16334 | World.AddNewSceneObject(group, true, llpos, Quaternion.Identity, Vector3.Zero); | ||
16335 | group.CreateScriptInstances(0, true, World.DefaultScriptEngine, 3); | ||
16336 | group.ScheduleGroupForFullUpdate(); | ||
16337 | |||
16338 | // objects rezzed with this method are die_at_edge by default. | ||
16339 | group.RootPart.SetDieAtEdge(true); | ||
16340 | |||
16341 | group.ResumeScripts(); | ||
16342 | |||
16343 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | ||
16344 | "object_rez", new Object[] { | ||
16345 | new LSL_String( | ||
16346 | group.RootPart.UUID.ToString()) }, | ||
16347 | new DetectParams[0])); | ||
15059 | } | 16348 | } |
15060 | 16349 | ||
15061 | public LSL_String llTransferLindenDollars(string destination, int amount) | 16350 | public LSL_String llTransferLindenDollars(string destination, int amount) |
@@ -15106,8 +16395,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
15106 | return; | 16395 | return; |
15107 | } | 16396 | } |
15108 | 16397 | ||
16398 | string reason; | ||
15109 | bool result = money.ObjectGiveMoney( | 16399 | bool result = money.ObjectGiveMoney( |
15110 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); | 16400 | m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount, txn, out reason); |
15111 | 16401 | ||
15112 | if (result) | 16402 | if (result) |
15113 | { | 16403 | { |
@@ -15115,7 +16405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
15115 | return; | 16405 | return; |
15116 | } | 16406 | } |
15117 | 16407 | ||
15118 | replydata = "LINDENDOLLAR_INSUFFICIENTFUNDS"; | 16408 | replydata = reason; |
15119 | } | 16409 | } |
15120 | finally | 16410 | finally |
15121 | { | 16411 | { |
@@ -15132,6 +16422,964 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
15132 | } | 16422 | } |
15133 | 16423 | ||
15134 | #endregion | 16424 | #endregion |
16425 | |||
16426 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
16427 | { | ||
16428 | SceneObjectGroup group = m_host.ParentGroup; | ||
16429 | |||
16430 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) | ||
16431 | return; | ||
16432 | if (group.IsAttachment) | ||
16433 | return; | ||
16434 | |||
16435 | if (frames.Data.Length > 0) // We are getting a new motion | ||
16436 | { | ||
16437 | if (group.RootPart.KeyframeMotion != null) | ||
16438 | group.RootPart.KeyframeMotion.Delete(); | ||
16439 | group.RootPart.KeyframeMotion = null; | ||
16440 | |||
16441 | int idx = 0; | ||
16442 | |||
16443 | KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; | ||
16444 | KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; | ||
16445 | |||
16446 | while (idx < options.Data.Length) | ||
16447 | { | ||
16448 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
16449 | int remain = options.Data.Length - idx; | ||
16450 | |||
16451 | switch (option) | ||
16452 | { | ||
16453 | case ScriptBaseClass.KFM_MODE: | ||
16454 | if (remain < 1) | ||
16455 | break; | ||
16456 | int modeval = (int)options.GetLSLIntegerItem(idx++); | ||
16457 | switch(modeval) | ||
16458 | { | ||
16459 | case ScriptBaseClass.KFM_FORWARD: | ||
16460 | mode = KeyframeMotion.PlayMode.Forward; | ||
16461 | break; | ||
16462 | case ScriptBaseClass.KFM_REVERSE: | ||
16463 | mode = KeyframeMotion.PlayMode.Reverse; | ||
16464 | break; | ||
16465 | case ScriptBaseClass.KFM_LOOP: | ||
16466 | mode = KeyframeMotion.PlayMode.Loop; | ||
16467 | break; | ||
16468 | case ScriptBaseClass.KFM_PING_PONG: | ||
16469 | mode = KeyframeMotion.PlayMode.PingPong; | ||
16470 | break; | ||
16471 | } | ||
16472 | break; | ||
16473 | case ScriptBaseClass.KFM_DATA: | ||
16474 | if (remain < 1) | ||
16475 | break; | ||
16476 | int dataval = (int)options.GetLSLIntegerItem(idx++); | ||
16477 | data = (KeyframeMotion.DataFormat)dataval; | ||
16478 | break; | ||
16479 | } | ||
16480 | } | ||
16481 | |||
16482 | group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data); | ||
16483 | |||
16484 | idx = 0; | ||
16485 | |||
16486 | int elemLength = 2; | ||
16487 | if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) | ||
16488 | elemLength = 3; | ||
16489 | |||
16490 | List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); | ||
16491 | while (idx < frames.Data.Length) | ||
16492 | { | ||
16493 | int remain = frames.Data.Length - idx; | ||
16494 | |||
16495 | if (remain < elemLength) | ||
16496 | break; | ||
16497 | |||
16498 | KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); | ||
16499 | frame.Position = null; | ||
16500 | frame.Rotation = null; | ||
16501 | |||
16502 | if ((data & KeyframeMotion.DataFormat.Translation) != 0) | ||
16503 | { | ||
16504 | LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); | ||
16505 | frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); | ||
16506 | } | ||
16507 | if ((data & KeyframeMotion.DataFormat.Rotation) != 0) | ||
16508 | { | ||
16509 | LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); | ||
16510 | Quaternion q = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); | ||
16511 | q.Normalize(); | ||
16512 | frame.Rotation = q; | ||
16513 | } | ||
16514 | |||
16515 | float tempf = (float)frames.GetLSLFloatItem(idx++); | ||
16516 | frame.TimeMS = (int)(tempf * 1000.0f); | ||
16517 | |||
16518 | keyframes.Add(frame); | ||
16519 | } | ||
16520 | |||
16521 | group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray()); | ||
16522 | group.RootPart.KeyframeMotion.Start(); | ||
16523 | } | ||
16524 | else | ||
16525 | { | ||
16526 | if (group.RootPart.KeyframeMotion == null) | ||
16527 | return; | ||
16528 | |||
16529 | if (options.Data.Length == 0) | ||
16530 | { | ||
16531 | group.RootPart.KeyframeMotion.Stop(); | ||
16532 | return; | ||
16533 | } | ||
16534 | |||
16535 | int code = (int)options.GetLSLIntegerItem(0); | ||
16536 | |||
16537 | int idx = 0; | ||
16538 | |||
16539 | while (idx < options.Data.Length) | ||
16540 | { | ||
16541 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
16542 | int remain = options.Data.Length - idx; | ||
16543 | |||
16544 | switch (option) | ||
16545 | { | ||
16546 | case ScriptBaseClass.KFM_COMMAND: | ||
16547 | int cmd = (int)options.GetLSLIntegerItem(idx++); | ||
16548 | switch (cmd) | ||
16549 | { | ||
16550 | case ScriptBaseClass.KFM_CMD_PLAY: | ||
16551 | group.RootPart.KeyframeMotion.Start(); | ||
16552 | break; | ||
16553 | case ScriptBaseClass.KFM_CMD_STOP: | ||
16554 | group.RootPart.KeyframeMotion.Stop(); | ||
16555 | break; | ||
16556 | case ScriptBaseClass.KFM_CMD_PAUSE: | ||
16557 | group.RootPart.KeyframeMotion.Pause(); | ||
16558 | break; | ||
16559 | } | ||
16560 | break; | ||
16561 | } | ||
16562 | } | ||
16563 | } | ||
16564 | } | ||
16565 | |||
16566 | protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed) | ||
16567 | { | ||
16568 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | ||
16569 | |||
16570 | int idx = 0; | ||
16571 | int idxStart = 0; | ||
16572 | |||
16573 | bool positionChanged = false; | ||
16574 | Vector3 finalPos = Vector3.Zero; | ||
16575 | |||
16576 | try | ||
16577 | { | ||
16578 | while (idx < rules.Length) | ||
16579 | { | ||
16580 | ++rulesParsed; | ||
16581 | int code = rules.GetLSLIntegerItem(idx++); | ||
16582 | |||
16583 | int remain = rules.Length - idx; | ||
16584 | idxStart = idx; | ||
16585 | |||
16586 | switch (code) | ||
16587 | { | ||
16588 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
16589 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
16590 | { | ||
16591 | if (remain < 1) | ||
16592 | return null; | ||
16593 | |||
16594 | LSL_Vector v; | ||
16595 | v = rules.GetVector3Item(idx++); | ||
16596 | |||
16597 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
16598 | |||
16599 | v = v + 2 * sitOffset; | ||
16600 | |||
16601 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
16602 | av.SendAvatarDataToAllAgents(); | ||
16603 | |||
16604 | } | ||
16605 | break; | ||
16606 | |||
16607 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
16608 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
16609 | { | ||
16610 | if (remain < 1) | ||
16611 | return null; | ||
16612 | |||
16613 | LSL_Rotation r; | ||
16614 | r = rules.GetQuaternionItem(idx++); | ||
16615 | |||
16616 | av.Rotation = r * llGetRootRotation(); | ||
16617 | av.SendAvatarDataToAllAgents(); | ||
16618 | } | ||
16619 | break; | ||
16620 | |||
16621 | // parse rest doing nothing but number of parameters error check | ||
16622 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
16623 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
16624 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
16625 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
16626 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
16627 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
16628 | case (int)ScriptBaseClass.PRIM_NAME: | ||
16629 | case (int)ScriptBaseClass.PRIM_DESC: | ||
16630 | if (remain < 1) | ||
16631 | return null; | ||
16632 | idx++; | ||
16633 | break; | ||
16634 | |||
16635 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
16636 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
16637 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
16638 | if (remain < 2) | ||
16639 | return null; | ||
16640 | idx += 2; | ||
16641 | break; | ||
16642 | |||
16643 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
16644 | if (remain < 3) | ||
16645 | return null; | ||
16646 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
16647 | remain = rules.Length - idx; | ||
16648 | switch (code) | ||
16649 | { | ||
16650 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
16651 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
16652 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
16653 | if (remain < 6) | ||
16654 | return null; | ||
16655 | idx += 6; | ||
16656 | break; | ||
16657 | |||
16658 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
16659 | if (remain < 5) | ||
16660 | return null; | ||
16661 | idx += 5; | ||
16662 | break; | ||
16663 | |||
16664 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | ||
16665 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | ||
16666 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | ||
16667 | if (remain < 11) | ||
16668 | return null; | ||
16669 | idx += 11; | ||
16670 | break; | ||
16671 | |||
16672 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
16673 | if (remain < 2) | ||
16674 | return null; | ||
16675 | idx += 2; | ||
16676 | break; | ||
16677 | } | ||
16678 | break; | ||
16679 | |||
16680 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
16681 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
16682 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
16683 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
16684 | if (remain < 3) | ||
16685 | return null; | ||
16686 | idx += 3; | ||
16687 | break; | ||
16688 | |||
16689 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
16690 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
16691 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
16692 | if (remain < 5) | ||
16693 | return null; | ||
16694 | idx += 5; | ||
16695 | break; | ||
16696 | |||
16697 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
16698 | if (remain < 7) | ||
16699 | return null; | ||
16700 | |||
16701 | idx += 7; | ||
16702 | break; | ||
16703 | |||
16704 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
16705 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
16706 | return null; | ||
16707 | |||
16708 | return rules.GetSublist(idx, -1); | ||
16709 | } | ||
16710 | } | ||
16711 | } | ||
16712 | catch (InvalidCastException e) | ||
16713 | { | ||
16714 | ShoutError(string.Format( | ||
16715 | "{0} error running rule #{1}: arg #{2} ", | ||
16716 | originFunc, rulesParsed, idx - idxStart) + e.Message); | ||
16717 | } | ||
16718 | finally | ||
16719 | { | ||
16720 | if (positionChanged) | ||
16721 | { | ||
16722 | av.OffsetPosition = finalPos; | ||
16723 | // av.SendAvatarDataToAllAgents(); | ||
16724 | av.SendTerseUpdateToAllClients(); | ||
16725 | positionChanged = false; | ||
16726 | } | ||
16727 | } | ||
16728 | return null; | ||
16729 | } | ||
16730 | |||
16731 | public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules, ref LSL_List res) | ||
16732 | { | ||
16733 | // avatars case | ||
16734 | // replies as SL wiki | ||
16735 | |||
16736 | // SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed | ||
16737 | SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? | ||
16738 | |||
16739 | int idx = 0; | ||
16740 | while (idx < rules.Length) | ||
16741 | { | ||
16742 | int code = (int)rules.GetLSLIntegerItem(idx++); | ||
16743 | int remain = rules.Length - idx; | ||
16744 | |||
16745 | switch (code) | ||
16746 | { | ||
16747 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
16748 | res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); | ||
16749 | break; | ||
16750 | |||
16751 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
16752 | res.Add(new LSL_Integer(0)); | ||
16753 | break; | ||
16754 | |||
16755 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
16756 | res.Add(new LSL_Integer(0)); | ||
16757 | break; | ||
16758 | |||
16759 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
16760 | res.Add(new LSL_Integer(0)); | ||
16761 | break; | ||
16762 | |||
16763 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
16764 | |||
16765 | Vector3 pos = avatar.OffsetPosition; | ||
16766 | |||
16767 | Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
16768 | pos -= sitOffset; | ||
16769 | |||
16770 | res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); | ||
16771 | break; | ||
16772 | |||
16773 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
16774 | Vector3 s = avatar.Appearance.AvatarSize; | ||
16775 | res.Add(new LSL_Vector(s.X, s.Y, s.Z)); | ||
16776 | |||
16777 | break; | ||
16778 | |||
16779 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
16780 | LSL_Rotation rot = new LSL_Rotation(avatar.Rotation.X, avatar.Rotation.Y, avatar.Rotation.Z, avatar.Rotation.W) / llGetRootRotation(); | ||
16781 | |||
16782 | res.Add(rot); | ||
16783 | break; | ||
16784 | |||
16785 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
16786 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); | ||
16787 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); | ||
16788 | res.Add(new LSL_Vector(0f,1.0f,0f)); | ||
16789 | res.Add(new LSL_Float(0.0f)); | ||
16790 | res.Add(new LSL_Vector(0, 0, 0)); | ||
16791 | res.Add(new LSL_Vector(1.0f,1.0f,0f)); | ||
16792 | res.Add(new LSL_Vector(0, 0, 0)); | ||
16793 | break; | ||
16794 | |||
16795 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
16796 | if (remain < 1) | ||
16797 | return null; | ||
16798 | |||
16799 | int face = (int)rules.GetLSLIntegerItem(idx++); | ||
16800 | if (face == ScriptBaseClass.ALL_SIDES) | ||
16801 | { | ||
16802 | for (face = 0; face < 21; face++) | ||
16803 | { | ||
16804 | res.Add(new LSL_String("")); | ||
16805 | res.Add(new LSL_Vector(0,0,0)); | ||
16806 | res.Add(new LSL_Vector(0,0,0)); | ||
16807 | res.Add(new LSL_Float(0.0)); | ||
16808 | } | ||
16809 | } | ||
16810 | else | ||
16811 | { | ||
16812 | if (face >= 0 && face < 21) | ||
16813 | { | ||
16814 | res.Add(new LSL_String("")); | ||
16815 | res.Add(new LSL_Vector(0,0,0)); | ||
16816 | res.Add(new LSL_Vector(0,0,0)); | ||
16817 | res.Add(new LSL_Float(0.0)); | ||
16818 | } | ||
16819 | } | ||
16820 | break; | ||
16821 | |||
16822 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
16823 | if (remain < 1) | ||
16824 | return null; | ||
16825 | |||
16826 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
16827 | |||
16828 | if (face == ScriptBaseClass.ALL_SIDES) | ||
16829 | { | ||
16830 | for (face = 0; face < 21; face++) | ||
16831 | { | ||
16832 | res.Add(new LSL_Vector(0,0,0)); | ||
16833 | res.Add(new LSL_Float(0)); | ||
16834 | } | ||
16835 | } | ||
16836 | else | ||
16837 | { | ||
16838 | res.Add(new LSL_Vector(0,0,0)); | ||
16839 | res.Add(new LSL_Float(0)); | ||
16840 | } | ||
16841 | break; | ||
16842 | |||
16843 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
16844 | if (remain < 1) | ||
16845 | return null; | ||
16846 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
16847 | |||
16848 | if (face == ScriptBaseClass.ALL_SIDES) | ||
16849 | { | ||
16850 | for (face = 0; face < 21; face++) | ||
16851 | { | ||
16852 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
16853 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
16854 | } | ||
16855 | } | ||
16856 | else | ||
16857 | { | ||
16858 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
16859 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
16860 | } | ||
16861 | break; | ||
16862 | |||
16863 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
16864 | if (remain < 1) | ||
16865 | return null; | ||
16866 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
16867 | |||
16868 | if (face == ScriptBaseClass.ALL_SIDES) | ||
16869 | { | ||
16870 | for (face = 0; face < 21; face++) | ||
16871 | { | ||
16872 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
16873 | } | ||
16874 | } | ||
16875 | else | ||
16876 | { | ||
16877 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
16878 | } | ||
16879 | break; | ||
16880 | |||
16881 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
16882 | res.Add(new LSL_Integer(0)); | ||
16883 | res.Add(new LSL_Integer(0));// softness | ||
16884 | res.Add(new LSL_Float(0.0f)); // gravity | ||
16885 | res.Add(new LSL_Float(0.0f)); // friction | ||
16886 | res.Add(new LSL_Float(0.0f)); // wind | ||
16887 | res.Add(new LSL_Float(0.0f)); // tension | ||
16888 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
16889 | break; | ||
16890 | |||
16891 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
16892 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
16893 | if (remain < 1) | ||
16894 | return null; | ||
16895 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
16896 | |||
16897 | if (face == ScriptBaseClass.ALL_SIDES) | ||
16898 | { | ||
16899 | for (face = 0; face < 21; face++) | ||
16900 | { | ||
16901 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
16902 | } | ||
16903 | } | ||
16904 | else | ||
16905 | { | ||
16906 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
16907 | } | ||
16908 | break; | ||
16909 | |||
16910 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
16911 | res.Add(new LSL_Integer(0)); | ||
16912 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
16913 | res.Add(new LSL_Float(0f)); // intensity | ||
16914 | res.Add(new LSL_Float(0f)); // radius | ||
16915 | res.Add(new LSL_Float(0f)); // falloff | ||
16916 | break; | ||
16917 | |||
16918 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
16919 | if (remain < 1) | ||
16920 | return null; | ||
16921 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
16922 | |||
16923 | if (face == ScriptBaseClass.ALL_SIDES) | ||
16924 | { | ||
16925 | for (face = 0; face < 21; face++) | ||
16926 | { | ||
16927 | res.Add(new LSL_Float(0f)); | ||
16928 | } | ||
16929 | } | ||
16930 | else | ||
16931 | { | ||
16932 | res.Add(new LSL_Float(0f)); | ||
16933 | } | ||
16934 | break; | ||
16935 | |||
16936 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
16937 | res.Add(new LSL_String("")); | ||
16938 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
16939 | res.Add(new LSL_Float(1.0f)); | ||
16940 | break; | ||
16941 | |||
16942 | case (int)ScriptBaseClass.PRIM_NAME: | ||
16943 | res.Add(new LSL_String(avatar.Name)); | ||
16944 | break; | ||
16945 | |||
16946 | case (int)ScriptBaseClass.PRIM_DESC: | ||
16947 | res.Add(new LSL_String("")); | ||
16948 | break; | ||
16949 | |||
16950 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
16951 | Quaternion lrot = avatar.Rotation; | ||
16952 | |||
16953 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
16954 | { | ||
16955 | lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset | ||
16956 | } | ||
16957 | res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); | ||
16958 | break; | ||
16959 | |||
16960 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
16961 | Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part | ||
16962 | Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); | ||
16963 | lpos -= lsitOffset; | ||
16964 | |||
16965 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
16966 | { | ||
16967 | lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim | ||
16968 | } | ||
16969 | res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); | ||
16970 | break; | ||
16971 | |||
16972 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
16973 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
16974 | return null; | ||
16975 | |||
16976 | return rules.GetSublist(idx, -1); | ||
16977 | } | ||
16978 | } | ||
16979 | |||
16980 | return null; | ||
16981 | } | ||
16982 | |||
16983 | public void llSetContentType(LSL_Key id, LSL_Integer content_type) | ||
16984 | { | ||
16985 | if (m_UrlModule != null) | ||
16986 | { | ||
16987 | string type = "text.plain"; | ||
16988 | if (content_type == (int)ScriptBaseClass.CONTENT_TYPE_HTML) | ||
16989 | type = "text/html"; | ||
16990 | |||
16991 | m_UrlModule.HttpContentType(new UUID(id),type); | ||
16992 | } | ||
16993 | } | ||
16994 | |||
16995 | public void llSetAnimationOverride(LSL_String animState, LSL_String anim) | ||
16996 | { | ||
16997 | string state = String.Empty; | ||
16998 | |||
16999 | foreach (KeyValuePair<string, string> kvp in MovementAnimationsForLSL) | ||
17000 | { | ||
17001 | if (kvp.Value.ToLower() == ((string)animState).ToLower()) | ||
17002 | { | ||
17003 | state = kvp.Key; | ||
17004 | break; | ||
17005 | } | ||
17006 | } | ||
17007 | |||
17008 | if (state == String.Empty) | ||
17009 | { | ||
17010 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "Invalid animation state " + animState); | ||
17011 | return; | ||
17012 | } | ||
17013 | |||
17014 | if (m_item.PermsGranter == UUID.Zero) | ||
17015 | { | ||
17016 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); | ||
17017 | return; | ||
17018 | } | ||
17019 | |||
17020 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS) == 0) | ||
17021 | { | ||
17022 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); | ||
17023 | return; | ||
17024 | } | ||
17025 | |||
17026 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
17027 | |||
17028 | if (presence == null) | ||
17029 | return; | ||
17030 | |||
17031 | UUID animID; | ||
17032 | |||
17033 | animID = ScriptUtils.GetAssetIdFromItemName(m_host, anim, (int)AssetType.Animation); | ||
17034 | |||
17035 | if (animID == UUID.Zero) | ||
17036 | { | ||
17037 | String animupper = ((string)anim).ToUpperInvariant(); | ||
17038 | DefaultAvatarAnimations.AnimsUUID.TryGetValue(animupper, out animID); | ||
17039 | } | ||
17040 | |||
17041 | if (animID == UUID.Zero) | ||
17042 | { | ||
17043 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "Animation not found"); | ||
17044 | return; | ||
17045 | } | ||
17046 | |||
17047 | presence.SetAnimationOverride(state, animID); | ||
17048 | } | ||
17049 | |||
17050 | public void llResetAnimationOverride(LSL_String animState) | ||
17051 | { | ||
17052 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
17053 | if (presence == null) | ||
17054 | return; | ||
17055 | |||
17056 | if (m_item.PermsGranter == UUID.Zero) | ||
17057 | { | ||
17058 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); | ||
17059 | return; | ||
17060 | } | ||
17061 | |||
17062 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS) == 0) | ||
17063 | { | ||
17064 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); | ||
17065 | return; | ||
17066 | } | ||
17067 | |||
17068 | if (animState == "ALL") | ||
17069 | { | ||
17070 | presence.SetAnimationOverride("ALL", UUID.Zero); | ||
17071 | return; | ||
17072 | } | ||
17073 | |||
17074 | string state = String.Empty; | ||
17075 | |||
17076 | foreach (KeyValuePair<string, string> kvp in MovementAnimationsForLSL) | ||
17077 | { | ||
17078 | if (kvp.Value.ToLower() == ((string)animState).ToLower()) | ||
17079 | { | ||
17080 | state = kvp.Key; | ||
17081 | break; | ||
17082 | } | ||
17083 | } | ||
17084 | |||
17085 | if (state == String.Empty) | ||
17086 | { | ||
17087 | return; | ||
17088 | } | ||
17089 | |||
17090 | presence.SetAnimationOverride(state, UUID.Zero); | ||
17091 | } | ||
17092 | |||
17093 | public LSL_String llGetAnimationOverride(LSL_String animState) | ||
17094 | { | ||
17095 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | ||
17096 | if (presence == null) | ||
17097 | return String.Empty; | ||
17098 | |||
17099 | if (m_item.PermsGranter == UUID.Zero) | ||
17100 | { | ||
17101 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); | ||
17102 | return String.Empty; | ||
17103 | } | ||
17104 | |||
17105 | if ((m_item.PermsMask & (ScriptBaseClass.PERMISSION_OVERRIDE_ANIMATIONS | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION)) == 0) | ||
17106 | { | ||
17107 | llShout(ScriptBaseClass.DEBUG_CHANNEL, "No permission to override animations"); | ||
17108 | return String.Empty; | ||
17109 | } | ||
17110 | |||
17111 | string state = String.Empty; | ||
17112 | |||
17113 | foreach (KeyValuePair<string, string> kvp in MovementAnimationsForLSL) | ||
17114 | { | ||
17115 | if (kvp.Value.ToLower() == ((string)animState).ToLower()) | ||
17116 | { | ||
17117 | state = kvp.Key; | ||
17118 | break; | ||
17119 | } | ||
17120 | } | ||
17121 | |||
17122 | if (state == String.Empty) | ||
17123 | { | ||
17124 | return String.Empty; | ||
17125 | } | ||
17126 | |||
17127 | UUID animID = presence.GetAnimationOverride(state); | ||
17128 | if (animID == UUID.Zero) | ||
17129 | return animState; | ||
17130 | |||
17131 | foreach (KeyValuePair<string, UUID> kvp in DefaultAvatarAnimations.AnimsUUID) | ||
17132 | { | ||
17133 | if (kvp.Value == animID) | ||
17134 | return kvp.Key.ToLower(); | ||
17135 | } | ||
17136 | |||
17137 | foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems()) | ||
17138 | { | ||
17139 | if (item.AssetID == animID) | ||
17140 | return item.Name; | ||
17141 | } | ||
17142 | |||
17143 | return String.Empty; | ||
17144 | } | ||
17145 | |||
17146 | public LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers) | ||
17147 | { | ||
17148 | OSD o = OSDParser.DeserializeJson(json); | ||
17149 | OSD specVal = JsonGetSpecific(o, specifiers, 0); | ||
17150 | |||
17151 | return specVal.AsString(); | ||
17152 | } | ||
17153 | |||
17154 | public LSL_List llJson2List(LSL_String json) | ||
17155 | { | ||
17156 | try | ||
17157 | { | ||
17158 | OSD o = OSDParser.DeserializeJson(json); | ||
17159 | return (LSL_List)ParseJsonNode(o); | ||
17160 | } | ||
17161 | catch (Exception) | ||
17162 | { | ||
17163 | return new LSL_List(ScriptBaseClass.JSON_INVALID); | ||
17164 | } | ||
17165 | } | ||
17166 | |||
17167 | private object ParseJsonNode(OSD node) | ||
17168 | { | ||
17169 | if (node.Type == OSDType.Integer) | ||
17170 | return new LSL_Integer(node.AsInteger()); | ||
17171 | if (node.Type == OSDType.Boolean) | ||
17172 | return new LSL_Integer(node.AsBoolean() ? 1 : 0); | ||
17173 | if (node.Type == OSDType.Real) | ||
17174 | return new LSL_Float(node.AsReal()); | ||
17175 | if (node.Type == OSDType.UUID || node.Type == OSDType.String) | ||
17176 | return new LSL_String(node.AsString()); | ||
17177 | if (node.Type == OSDType.Array) | ||
17178 | { | ||
17179 | LSL_List resp = new LSL_List(); | ||
17180 | OSDArray ar = node as OSDArray; | ||
17181 | foreach (OSD o in ar) | ||
17182 | resp.Add(ParseJsonNode(o)); | ||
17183 | return resp; | ||
17184 | } | ||
17185 | if (node.Type == OSDType.Map) | ||
17186 | { | ||
17187 | LSL_List resp = new LSL_List(); | ||
17188 | OSDMap ar = node as OSDMap; | ||
17189 | foreach (KeyValuePair<string, OSD> o in ar) | ||
17190 | { | ||
17191 | resp.Add(new LSL_String(o.Key)); | ||
17192 | resp.Add(ParseJsonNode(o.Value)); | ||
17193 | } | ||
17194 | return resp; | ||
17195 | } | ||
17196 | throw new Exception(ScriptBaseClass.JSON_INVALID); | ||
17197 | } | ||
17198 | |||
17199 | public LSL_String llList2Json(LSL_String type, LSL_List values) | ||
17200 | { | ||
17201 | try | ||
17202 | { | ||
17203 | if (type == ScriptBaseClass.JSON_ARRAY) | ||
17204 | { | ||
17205 | OSDArray array = new OSDArray(); | ||
17206 | foreach (object o in values.Data) | ||
17207 | { | ||
17208 | array.Add(ListToJson(o)); | ||
17209 | } | ||
17210 | return OSDParser.SerializeJsonString(array); | ||
17211 | } | ||
17212 | else if (type == ScriptBaseClass.JSON_OBJECT) | ||
17213 | { | ||
17214 | OSDMap map = new OSDMap(); | ||
17215 | for (int i = 0; i < values.Data.Length; i += 2) | ||
17216 | { | ||
17217 | if (!(values.Data[i] is LSL_String)) | ||
17218 | return ScriptBaseClass.JSON_INVALID; | ||
17219 | map.Add(((LSL_String)values.Data[i]).m_string, ListToJson(values.Data[i + 1])); | ||
17220 | } | ||
17221 | return OSDParser.SerializeJsonString(map); | ||
17222 | } | ||
17223 | return ScriptBaseClass.JSON_INVALID; | ||
17224 | } | ||
17225 | catch (Exception ex) | ||
17226 | { | ||
17227 | return ex.Message; | ||
17228 | } | ||
17229 | } | ||
17230 | |||
17231 | private OSD ListToJson(object o) | ||
17232 | { | ||
17233 | if (o is LSL_Float) | ||
17234 | return OSD.FromReal(((LSL_Float)o).value); | ||
17235 | if (o is LSL_Integer) | ||
17236 | { | ||
17237 | int i = ((LSL_Integer)o).value; | ||
17238 | if (i == 0) | ||
17239 | return OSD.FromBoolean(false); | ||
17240 | else if (i == 1) | ||
17241 | return OSD.FromBoolean(true); | ||
17242 | return OSD.FromInteger(i); | ||
17243 | } | ||
17244 | if (o is LSL_Rotation) | ||
17245 | return OSD.FromString(((LSL_Rotation)o).ToString()); | ||
17246 | if (o is LSL_Vector) | ||
17247 | return OSD.FromString(((LSL_Vector)o).ToString()); | ||
17248 | if (o is LSL_String) | ||
17249 | { | ||
17250 | string str = ((LSL_String)o).m_string; | ||
17251 | if (str == ScriptBaseClass.JSON_NULL) | ||
17252 | return new OSD(); | ||
17253 | return OSD.FromString(str); | ||
17254 | } | ||
17255 | throw new Exception(ScriptBaseClass.JSON_INVALID); | ||
17256 | } | ||
17257 | |||
17258 | private OSD JsonGetSpecific(OSD o, LSL_List specifiers, int i) | ||
17259 | { | ||
17260 | object spec = specifiers.Data[i]; | ||
17261 | OSD nextVal = null; | ||
17262 | if (o is OSDArray) | ||
17263 | { | ||
17264 | if (spec is LSL_Integer) | ||
17265 | nextVal = ((OSDArray)o)[((LSL_Integer)spec).value]; | ||
17266 | } | ||
17267 | if (o is OSDMap) | ||
17268 | { | ||
17269 | if (spec is LSL_String) | ||
17270 | nextVal = ((OSDMap)o)[((LSL_String)spec).m_string]; | ||
17271 | } | ||
17272 | if (nextVal != null) | ||
17273 | { | ||
17274 | if (specifiers.Data.Length - 1 > i) | ||
17275 | return JsonGetSpecific(nextVal, specifiers, i + 1); | ||
17276 | } | ||
17277 | return nextVal; | ||
17278 | } | ||
17279 | |||
17280 | public LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value) | ||
17281 | { | ||
17282 | try | ||
17283 | { | ||
17284 | OSD o = OSDParser.DeserializeJson(json); | ||
17285 | JsonSetSpecific(o, specifiers, 0, value); | ||
17286 | return OSDParser.SerializeJsonString(o); | ||
17287 | } | ||
17288 | catch (Exception) | ||
17289 | { | ||
17290 | } | ||
17291 | return ScriptBaseClass.JSON_INVALID; | ||
17292 | } | ||
17293 | |||
17294 | private void JsonSetSpecific(OSD o, LSL_List specifiers, int i, LSL_String val) | ||
17295 | { | ||
17296 | object spec = specifiers.Data[i]; | ||
17297 | // 20131224 not used object specNext = i+1 == specifiers.Data.Length ? null : specifiers.Data[i+1]; | ||
17298 | OSD nextVal = null; | ||
17299 | if (o is OSDArray) | ||
17300 | { | ||
17301 | OSDArray array = ((OSDArray)o); | ||
17302 | if (spec is LSL_Integer) | ||
17303 | { | ||
17304 | int v = ((LSL_Integer)spec).value; | ||
17305 | if (v >= array.Count) | ||
17306 | array.Add(JsonBuildRestOfSpec(specifiers, i + 1, val)); | ||
17307 | else | ||
17308 | nextVal = ((OSDArray)o)[v]; | ||
17309 | } | ||
17310 | else if (spec is LSL_String && ((LSL_String)spec) == ScriptBaseClass.JSON_APPEND) | ||
17311 | array.Add(JsonBuildRestOfSpec(specifiers, i + 1, val)); | ||
17312 | } | ||
17313 | if (o is OSDMap) | ||
17314 | { | ||
17315 | if (spec is LSL_String) | ||
17316 | { | ||
17317 | OSDMap map = ((OSDMap)o); | ||
17318 | if (map.ContainsKey(((LSL_String)spec).m_string)) | ||
17319 | nextVal = map[((LSL_String)spec).m_string]; | ||
17320 | else | ||
17321 | map.Add(((LSL_String)spec).m_string, JsonBuildRestOfSpec(specifiers, i + 1, val)); | ||
17322 | } | ||
17323 | } | ||
17324 | if (nextVal != null) | ||
17325 | { | ||
17326 | if (specifiers.Data.Length - 1 > i) | ||
17327 | { | ||
17328 | JsonSetSpecific(nextVal, specifiers, i + 1, val); | ||
17329 | return; | ||
17330 | } | ||
17331 | } | ||
17332 | } | ||
17333 | |||
17334 | private OSD JsonBuildRestOfSpec(LSL_List specifiers, int i, LSL_String val) | ||
17335 | { | ||
17336 | object spec = i >= specifiers.Data.Length ? null : specifiers.Data[i]; | ||
17337 | // 20131224 not used object specNext = i+1 >= specifiers.Data.Length ? null : specifiers.Data[i+1]; | ||
17338 | |||
17339 | if (spec == null) | ||
17340 | return OSD.FromString(val); | ||
17341 | |||
17342 | if (spec is LSL_Integer || | ||
17343 | (spec is LSL_String && ((LSL_String)spec) == ScriptBaseClass.JSON_APPEND)) | ||
17344 | { | ||
17345 | OSDArray array = new OSDArray(); | ||
17346 | array.Add(JsonBuildRestOfSpec(specifiers, i + 1, val)); | ||
17347 | return array; | ||
17348 | } | ||
17349 | else if (spec is LSL_String) | ||
17350 | { | ||
17351 | OSDMap map = new OSDMap(); | ||
17352 | map.Add((LSL_String)spec, JsonBuildRestOfSpec(specifiers, i + 1, val)); | ||
17353 | return map; | ||
17354 | } | ||
17355 | return new OSD(); | ||
17356 | } | ||
17357 | |||
17358 | public LSL_String llJsonValueType(LSL_String json, LSL_List specifiers) | ||
17359 | { | ||
17360 | OSD o = OSDParser.DeserializeJson(json); | ||
17361 | OSD specVal = JsonGetSpecific(o, specifiers, 0); | ||
17362 | if (specVal == null) | ||
17363 | return ScriptBaseClass.JSON_INVALID; | ||
17364 | switch (specVal.Type) | ||
17365 | { | ||
17366 | case OSDType.Array: | ||
17367 | return ScriptBaseClass.JSON_ARRAY; | ||
17368 | case OSDType.Boolean: | ||
17369 | return specVal.AsBoolean() ? ScriptBaseClass.JSON_TRUE : ScriptBaseClass.JSON_FALSE; | ||
17370 | case OSDType.Integer: | ||
17371 | case OSDType.Real: | ||
17372 | return ScriptBaseClass.JSON_NUMBER; | ||
17373 | case OSDType.Map: | ||
17374 | return ScriptBaseClass.JSON_OBJECT; | ||
17375 | case OSDType.String: | ||
17376 | case OSDType.UUID: | ||
17377 | return ScriptBaseClass.JSON_STRING; | ||
17378 | case OSDType.Unknown: | ||
17379 | return ScriptBaseClass.JSON_NULL; | ||
17380 | } | ||
17381 | return ScriptBaseClass.JSON_INVALID; | ||
17382 | } | ||
15135 | } | 17383 | } |
15136 | 17384 | ||
15137 | public class NotecardCache | 17385 | public class NotecardCache |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 1458c95..7bd4fa7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -136,7 +136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
136 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); | 136 | // ((MethodInfo)MethodBase.GetCurrentMethod()).ReturnType); |
137 | 137 | ||
138 | Type returntype = m_comms.LookupReturnType(fname); | 138 | Type returntype = m_comms.LookupReturnType(fname); |
139 | if (returntype != typeof(string)) | 139 | if (returntype != typeof(void)) |
140 | MODError(String.Format("return type mismatch for {0}",fname)); | 140 | MODError(String.Format("return type mismatch for {0}",fname)); |
141 | 141 | ||
142 | modInvoke(fname,parms); | 142 | modInvoke(fname,parms); |
@@ -329,6 +329,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
329 | if (result != null) | 329 | if (result != null) |
330 | return result; | 330 | return result; |
331 | 331 | ||
332 | Type returntype = m_comms.LookupReturnType(fname); | ||
333 | if (returntype == typeof(void)) | ||
334 | return null; | ||
335 | |||
332 | MODError(String.Format("Invocation of {0} failed; null return value",fname)); | 336 | MODError(String.Format("Invocation of {0} failed; null return value",fname)); |
333 | } | 337 | } |
334 | catch (Exception e) | 338 | catch (Exception e) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e799714..5d8f0f6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -140,6 +140,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
140 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | 140 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; |
141 | internal float m_ScriptDelayFactor = 1.0f; | 141 | internal float m_ScriptDelayFactor = 1.0f; |
142 | internal float m_ScriptDistanceFactor = 1.0f; | 142 | internal float m_ScriptDistanceFactor = 1.0f; |
143 | internal bool m_debuggerSafe = false; | ||
143 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 144 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
144 | 145 | ||
145 | protected IUrlModule m_UrlModule = null; | 146 | protected IUrlModule m_UrlModule = null; |
@@ -150,6 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
150 | m_ScriptEngine = scriptEngine; | 151 | m_ScriptEngine = scriptEngine; |
151 | m_host = host; | 152 | m_host = host; |
152 | m_item = item; | 153 | m_item = item; |
154 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | ||
153 | 155 | ||
154 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 156 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
155 | 157 | ||
@@ -216,7 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
216 | 218 | ||
217 | internal void OSSLError(string msg) | 219 | internal void OSSLError(string msg) |
218 | { | 220 | { |
219 | throw new ScriptException("OSSL Runtime Error: " + msg); | 221 | if (m_debuggerSafe) |
222 | { | ||
223 | OSSLShoutError(msg); | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | throw new ScriptException("OSSL Runtime Error: " + msg); | ||
228 | } | ||
220 | } | 229 | } |
221 | 230 | ||
222 | /// <summary> | 231 | /// <summary> |
@@ -820,7 +829,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
820 | private void TeleportAgent(string agent, int regionX, int regionY, | 829 | private void TeleportAgent(string agent, int regionX, int regionY, |
821 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) | 830 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) |
822 | { | 831 | { |
832 | <<<<<<< HEAD | ||
823 | // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); | 833 | // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); |
834 | ======= | ||
835 | >>>>>>> avn/ubitvar | ||
824 | ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY); | 836 | ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY); |
825 | 837 | ||
826 | m_host.AddScriptLPS(1); | 838 | m_host.AddScriptLPS(1); |
@@ -993,18 +1005,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
993 | if (target != null) | 1005 | if (target != null) |
994 | { | 1006 | { |
995 | UUID animID=UUID.Zero; | 1007 | UUID animID=UUID.Zero; |
996 | lock (m_host.TaskInventory) | 1008 | m_host.TaskInventory.LockItemsForRead(true); |
1009 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
997 | { | 1010 | { |
998 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 1011 | if (inv.Value.Name == animation) |
999 | { | 1012 | { |
1000 | if (inv.Value.Name == animation) | 1013 | if (inv.Value.Type == (int)AssetType.Animation) |
1001 | { | 1014 | animID = inv.Value.AssetID; |
1002 | if (inv.Value.Type == (int)AssetType.Animation) | 1015 | continue; |
1003 | animID = inv.Value.AssetID; | ||
1004 | continue; | ||
1005 | } | ||
1006 | } | 1016 | } |
1007 | } | 1017 | } |
1018 | m_host.TaskInventory.LockItemsForRead(false); | ||
1008 | if (animID == UUID.Zero) | 1019 | if (animID == UUID.Zero) |
1009 | target.Animator.AddAnimation(animation, m_host.UUID); | 1020 | target.Animator.AddAnimation(animation, m_host.UUID); |
1010 | else | 1021 | else |
@@ -1046,6 +1057,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1046 | animID = UUID.Zero; | 1057 | animID = UUID.Zero; |
1047 | } | 1058 | } |
1048 | 1059 | ||
1060 | |||
1049 | if (animID == UUID.Zero) | 1061 | if (animID == UUID.Zero) |
1050 | target.Animator.RemoveAnimation(animation); | 1062 | target.Animator.RemoveAnimation(animation); |
1051 | else | 1063 | else |
@@ -1487,7 +1499,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1487 | return; | 1499 | return; |
1488 | } | 1500 | } |
1489 | 1501 | ||
1490 | if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions)) | 1502 | if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions, false)) |
1491 | { | 1503 | { |
1492 | OSSLShoutError("You do not have permission to modify the parcel"); | 1504 | OSSLShoutError("You do not have permission to modify the parcel"); |
1493 | return; | 1505 | return; |
@@ -1722,7 +1734,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1722 | } | 1734 | } |
1723 | } | 1735 | } |
1724 | 1736 | ||
1725 | public Object osParseJSONNew(string JSON) | 1737 | private Object osParseJSONNew(string JSON) |
1726 | { | 1738 | { |
1727 | CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); | 1739 | CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); |
1728 | 1740 | ||
@@ -1934,15 +1946,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1934 | { | 1946 | { |
1935 | UUID assetID = UUID.Zero; | 1947 | UUID assetID = UUID.Zero; |
1936 | 1948 | ||
1937 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) | 1949 | bool notecardNameIsUUID = UUID.TryParse(notecardNameOrUuid, out assetID); |
1950 | |||
1951 | if (!notecardNameIsUUID) | ||
1938 | { | 1952 | { |
1939 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1953 | assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); |
1940 | { | ||
1941 | if (item.Type == 7 && item.Name == notecardNameOrUuid) | ||
1942 | { | ||
1943 | assetID = item.AssetID; | ||
1944 | } | ||
1945 | } | ||
1946 | } | 1954 | } |
1947 | 1955 | ||
1948 | if (assetID == UUID.Zero) | 1956 | if (assetID == UUID.Zero) |
@@ -1953,13 +1961,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1953 | AssetBase a = World.AssetService.Get(assetID.ToString()); | 1961 | AssetBase a = World.AssetService.Get(assetID.ToString()); |
1954 | 1962 | ||
1955 | if (a == null) | 1963 | if (a == null) |
1956 | return UUID.Zero; | 1964 | { |
1965 | // Whoops, it's still possible here that the notecard name was properly | ||
1966 | // formatted like a UUID but isn't an asset UUID so lets look it up by name after all | ||
1967 | assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); | ||
1968 | if (assetID == UUID.Zero) | ||
1969 | return UUID.Zero; | ||
1970 | |||
1971 | if (!NotecardCache.IsCached(assetID)) | ||
1972 | { | ||
1973 | a = World.AssetService.Get(assetID.ToString()); | ||
1974 | |||
1975 | if (a == null) | ||
1976 | { | ||
1977 | return UUID.Zero; | ||
1978 | } | ||
1979 | } | ||
1980 | } | ||
1957 | 1981 | ||
1958 | NotecardCache.Cache(assetID, a.Data); | 1982 | NotecardCache.Cache(assetID, a.Data); |
1959 | }; | 1983 | }; |
1960 | 1984 | ||
1961 | return assetID; | 1985 | return assetID; |
1962 | } | 1986 | } |
1987 | protected UUID SearchTaskInventoryForAssetId(string name) | ||
1988 | { | ||
1989 | UUID assetId = UUID.Zero; | ||
1990 | m_host.TaskInventory.LockItemsForRead(true); | ||
1991 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1992 | { | ||
1993 | if (item.Type == 7 && item.Name == name) | ||
1994 | { | ||
1995 | assetId = item.AssetID; | ||
1996 | } | ||
1997 | } | ||
1998 | m_host.TaskInventory.LockItemsForRead(false); | ||
1999 | return assetId; | ||
2000 | } | ||
1963 | 2001 | ||
1964 | /// <summary> | 2002 | /// <summary> |
1965 | /// Directly get an entire notecard at once. | 2003 | /// Directly get an entire notecard at once. |
@@ -2544,7 +2582,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2544 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 2582 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
2545 | m_host.AddScriptLPS(1); | 2583 | m_host.AddScriptLPS(1); |
2546 | 2584 | ||
2547 | return NpcCreate(firstname, lastname, position, notecard, false, false); | 2585 | return NpcCreate(firstname, lastname, position, notecard, true, false); |
2548 | } | 2586 | } |
2549 | 2587 | ||
2550 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) | 2588 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) |
@@ -2555,24 +2593,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | return NpcCreate( | 2593 | return NpcCreate( |
2556 | firstname, lastname, position, notecard, | 2594 | firstname, lastname, position, notecard, |
2557 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, | 2595 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, |
2558 | (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | 2596 | false); |
2597 | // (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | ||
2559 | } | 2598 | } |
2560 | 2599 | ||
2561 | private LSL_Key NpcCreate( | 2600 | private LSL_Key NpcCreate( |
2562 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) | 2601 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) |
2563 | { | 2602 | { |
2603 | if (!owned) | ||
2604 | OSSLError("Unowned NPCs are unsupported"); | ||
2605 | |||
2606 | string groupTitle = String.Empty; | ||
2607 | |||
2608 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) | ||
2609 | return new LSL_Key(UUID.Zero.ToString()); | ||
2610 | |||
2611 | if (firstname != String.Empty || lastname != String.Empty) | ||
2612 | { | ||
2613 | if (firstname != "Shown outfit:") | ||
2614 | groupTitle = "- NPC -"; | ||
2615 | } | ||
2616 | |||
2564 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2617 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2565 | if (module != null) | 2618 | if (module != null) |
2566 | { | 2619 | { |
2567 | AvatarAppearance appearance = null; | 2620 | AvatarAppearance appearance = null; |
2568 | 2621 | ||
2569 | UUID id; | 2622 | // UUID id; |
2570 | if (UUID.TryParse(notecard, out id)) | 2623 | // if (UUID.TryParse(notecard, out id)) |
2571 | { | 2624 | // { |
2572 | ScenePresence clonePresence = World.GetScenePresence(id); | 2625 | // ScenePresence clonePresence = World.GetScenePresence(id); |
2573 | if (clonePresence != null) | 2626 | // if (clonePresence != null) |
2574 | appearance = clonePresence.Appearance; | 2627 | // appearance = clonePresence.Appearance; |
2575 | } | 2628 | // } |
2576 | 2629 | ||
2577 | if (appearance == null) | 2630 | if (appearance == null) |
2578 | { | 2631 | { |
@@ -2580,9 +2633,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2580 | 2633 | ||
2581 | if (appearanceSerialized != null) | 2634 | if (appearanceSerialized != null) |
2582 | { | 2635 | { |
2583 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2636 | try |
2584 | appearance = new AvatarAppearance(); | 2637 | { |
2585 | appearance.Unpack(appearanceOsd); | 2638 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2639 | appearance = new AvatarAppearance(); | ||
2640 | appearance.Unpack(appearanceOsd); | ||
2641 | } | ||
2642 | catch | ||
2643 | { | ||
2644 | return UUID.Zero.ToString(); | ||
2645 | } | ||
2586 | } | 2646 | } |
2587 | else | 2647 | else |
2588 | { | 2648 | { |
@@ -2601,6 +2661,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2601 | World, | 2661 | World, |
2602 | appearance); | 2662 | appearance); |
2603 | 2663 | ||
2664 | ScenePresence sp; | ||
2665 | if (World.TryGetScenePresence(x, out sp)) | ||
2666 | { | ||
2667 | sp.Grouptitle = groupTitle; | ||
2668 | sp.SendAvatarDataToAllAgents(); | ||
2669 | } | ||
2604 | return new LSL_Key(x.ToString()); | 2670 | return new LSL_Key(x.ToString()); |
2605 | } | 2671 | } |
2606 | 2672 | ||
@@ -2898,16 +2964,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2898 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); | 2964 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); |
2899 | m_host.AddScriptLPS(1); | 2965 | m_host.AddScriptLPS(1); |
2900 | 2966 | ||
2901 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2967 | ManualResetEvent ev = new ManualResetEvent(false); |
2902 | if (module != null) | ||
2903 | { | ||
2904 | UUID npcId = new UUID(npc.m_string); | ||
2905 | 2968 | ||
2906 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2969 | Util.FireAndForget(delegate(object x) { |
2907 | return; | 2970 | try |
2971 | { | ||
2972 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2973 | if (module != null) | ||
2974 | { | ||
2975 | UUID npcId = new UUID(npc.m_string); | ||
2908 | 2976 | ||
2909 | module.DeleteNPC(npcId, World); | 2977 | ILandObject l = World.LandChannel.GetLandObject(m_host.GroupPosition.X, m_host.GroupPosition.Y); |
2910 | } | 2978 | if (l == null || m_host.OwnerID != l.LandData.OwnerID) |
2979 | { | ||
2980 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2981 | return; | ||
2982 | } | ||
2983 | |||
2984 | module.DeleteNPC(npcId, World); | ||
2985 | } | ||
2986 | } | ||
2987 | finally | ||
2988 | { | ||
2989 | ev.Set(); | ||
2990 | } | ||
2991 | }); | ||
2992 | ev.WaitOne(); | ||
2911 | } | 2993 | } |
2912 | 2994 | ||
2913 | public void osNpcPlayAnimation(LSL_Key npc, string animation) | 2995 | public void osNpcPlayAnimation(LSL_Key npc, string animation) |
@@ -3183,9 +3265,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3183 | } | 3265 | } |
3184 | else | 3266 | else |
3185 | { | 3267 | { |
3268 | <<<<<<< HEAD | ||
3186 | Scene scene = m_ScriptEngine.World; | 3269 | Scene scene = m_ScriptEngine.World; |
3187 | GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); | 3270 | GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); |
3188 | return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeX, Constants.RegionHeight); | 3271 | return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeX, Constants.RegionHeight); |
3272 | ======= | ||
3273 | return new LSL_Vector((float)World.RegionInfo.RegionSizeX, | ||
3274 | (float)World.RegionInfo.RegionSizeY, | ||
3275 | (float)World.RegionInfo.RegionSizeZ ); | ||
3276 | >>>>>>> avn/ubitvar | ||
3189 | } | 3277 | } |
3190 | } | 3278 | } |
3191 | 3279 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 64dc2e2..7bfe27b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -93,7 +93,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
93 | private const int AGENT = 1; | 93 | private const int AGENT = 1; |
94 | private const int AGENT_BY_USERNAME = 0x10; | 94 | private const int AGENT_BY_USERNAME = 0x10; |
95 | private const int NPC = 0x20; | 95 | private const int NPC = 0x20; |
96 | private const int OS_NPC = 0x01000000; | ||
97 | private const int ACTIVE = 2; | 96 | private const int ACTIVE = 2; |
98 | private const int PASSIVE = 4; | 97 | private const int PASSIVE = 4; |
99 | private const int SCRIPTED = 8; | 98 | private const int SCRIPTED = 8; |
@@ -240,7 +239,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
240 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); | 239 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); |
241 | 240 | ||
242 | // Is the sensor type is AGENT and not SCRIPTED then include agents | 241 | // Is the sensor type is AGENT and not SCRIPTED then include agents |
243 | if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) | 242 | if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) |
244 | { | 243 | { |
245 | sensedEntities.AddRange(doAgentSensor(ts)); | 244 | sensedEntities.AddRange(doAgentSensor(ts)); |
246 | } | 245 | } |
@@ -339,7 +338,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
339 | float dy; | 338 | float dy; |
340 | float dz; | 339 | float dz; |
341 | 340 | ||
342 | Quaternion q = SensePoint.GetWorldRotation(); | 341 | // Quaternion q = SensePoint.RotationOffset; |
342 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | ||
343 | if (SensePoint.ParentGroup.IsAttachment) | 343 | if (SensePoint.ParentGroup.IsAttachment) |
344 | { | 344 | { |
345 | // In attachments, rotate the sensor cone with the | 345 | // In attachments, rotate the sensor cone with the |
@@ -358,7 +358,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
358 | if (avatar == null) | 358 | if (avatar == null) |
359 | return sensedEntities; | 359 | return sensedEntities; |
360 | 360 | ||
361 | q = avatar.GetWorldRotation() * q; | 361 | fromRegionPos = avatar.AbsolutePosition; |
362 | q = avatar.Rotation; | ||
362 | } | 363 | } |
363 | 364 | ||
364 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); | 365 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
@@ -402,7 +403,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
402 | objtype = 0; | 403 | objtype = 0; |
403 | 404 | ||
404 | part = ((SceneObjectGroup)ent).RootPart; | 405 | part = ((SceneObjectGroup)ent).RootPart; |
405 | if (part.ParentGroup.AttachmentPoint != 0) // Attached so ignore | 406 | if (part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.Tree && |
407 | part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
408 | part.ParentGroup.AttachmentPoint != 0) // Attached so ignore | ||
406 | continue; | 409 | continue; |
407 | 410 | ||
408 | if (part.Inventory.ContainsScripts()) | 411 | if (part.Inventory.ContainsScripts()) |
@@ -489,8 +492,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
489 | // Don't proceed if the avatar for this attachment has since been removed from the scene. | 492 | // Don't proceed if the avatar for this attachment has since been removed from the scene. |
490 | if (avatar == null) | 493 | if (avatar == null) |
491 | return sensedEntities; | 494 | return sensedEntities; |
492 | 495 | fromRegionPos = avatar.AbsolutePosition; | |
493 | q = avatar.GetWorldRotation() * q; | 496 | q = avatar.Rotation; |
494 | } | 497 | } |
495 | 498 | ||
496 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); | 499 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
@@ -506,7 +509,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
506 | // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", | 509 | // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", |
507 | // presence.Name, presence.PresenceType, ts.name, ts.type); | 510 | // presence.Name, presence.PresenceType, ts.name, ts.type); |
508 | 511 | ||
509 | if ((ts.type & NPC) == 0 && (ts.type & OS_NPC) == 0 && presence.PresenceType == PresenceType.Npc) | 512 | if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) |
510 | { | 513 | { |
511 | INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); | 514 | INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); |
512 | if (npcData == null || !npcData.SenseAsAgent) | 515 | if (npcData == null || !npcData.SenseAsAgent) |
@@ -546,7 +549,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
546 | return; | 549 | return; |
547 | 550 | ||
548 | toRegionPos = presence.AbsolutePosition; | 551 | toRegionPos = presence.AbsolutePosition; |
549 | dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); | 552 | dis = Util.GetDistanceTo(toRegionPos, fromRegionPos); |
553 | if (presence.IsSatOnObject && presence.ParentPart != null && | ||
554 | presence.ParentPart.ParentGroup != null && | ||
555 | presence.ParentPart.ParentGroup.RootPart != null) | ||
556 | { | ||
557 | Vector3 rpos = presence.ParentPart.ParentGroup.RootPart.AbsolutePosition; | ||
558 | double dis2 = Util.GetDistanceTo(rpos, fromRegionPos); | ||
559 | if (dis > dis2) | ||
560 | dis = dis2; | ||
561 | } | ||
550 | 562 | ||
551 | // Disabled for now since all osNpc* methods check for appropriate ownership permission. | 563 | // Disabled for now since all osNpc* methods check for appropriate ownership permission. |
552 | // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not | 564 | // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not |
@@ -706,4 +718,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
706 | return retList; | 718 | return retList; |
707 | } | 719 | } |
708 | } | 720 | } |
709 | } \ No newline at end of file | 721 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index 0b14565..5b1fdc0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -123,25 +123,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
123 | if (Timers.Count == 0) | 123 | if (Timers.Count == 0) |
124 | return; | 124 | return; |
125 | 125 | ||
126 | Dictionary<string, TimerInfo> tvals; | ||
126 | lock (TimerListLock) | 127 | lock (TimerListLock) |
127 | { | 128 | { |
128 | // Go through all timers | 129 | // Go through all timers |
129 | Dictionary<string, TimerInfo>.ValueCollection tvals = Timers.Values; | 130 | tvals = new Dictionary<string, TimerInfo>(Timers); |
130 | foreach (TimerInfo ts in tvals) | 131 | } |
132 | |||
133 | foreach (TimerInfo ts in tvals.Values) | ||
134 | { | ||
135 | // Time has passed? | ||
136 | if (ts.next < DateTime.Now.Ticks) | ||
131 | { | 137 | { |
132 | // Time has passed? | 138 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
133 | if (ts.next < DateTime.Now.Ticks) | 139 | // Add it to queue |
134 | { | 140 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
135 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 141 | new EventParams("timer", new Object[0], |
136 | // Add it to queue | 142 | new DetectParams[0])); |
137 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 143 | // set next interval |
138 | new EventParams("timer", new Object[0], | 144 | |
139 | new DetectParams[0])); | 145 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
140 | // set next interval | 146 | ts.next = DateTime.Now.Ticks + ts.interval; |
141 | |||
142 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
143 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
144 | } | ||
145 | } | 147 | } |
146 | } | 148 | } |
147 | } | 149 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..ab215f3 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
40 | { | ||
41 | public interface ICM_Api | ||
42 | { | ||
43 | string cmDetectedCountry(int num); | ||
44 | string cmGetAgentCountry(key key); | ||
45 | } | ||
46 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 3d58573..a3bb7d6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -127,6 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
127 | LSL_String llGetEnv(LSL_String name); | 127 | LSL_String llGetEnv(LSL_String name); |
128 | LSL_Vector llGetForce(); | 128 | LSL_Vector llGetForce(); |
129 | LSL_Integer llGetFreeMemory(); | 129 | LSL_Integer llGetFreeMemory(); |
130 | LSL_Integer llGetUsedMemory(); | ||
130 | LSL_Integer llGetFreeURLs(); | 131 | LSL_Integer llGetFreeURLs(); |
131 | LSL_Vector llGetGeometricCenter(); | 132 | LSL_Vector llGetGeometricCenter(); |
132 | LSL_Float llGetGMTclock(); | 133 | LSL_Float llGetGMTclock(); |
@@ -204,12 +205,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
204 | LSL_String llGetTimestamp(); | 205 | LSL_String llGetTimestamp(); |
205 | LSL_Vector llGetTorque(); | 206 | LSL_Vector llGetTorque(); |
206 | LSL_Integer llGetUnixTime(); | 207 | LSL_Integer llGetUnixTime(); |
207 | LSL_Integer llGetUsedMemory(); | ||
208 | LSL_Vector llGetVel(); | 208 | LSL_Vector llGetVel(); |
209 | LSL_Float llGetWallclock(); | 209 | LSL_Float llGetWallclock(); |
210 | void llGiveInventory(string destination, string inventory); | 210 | void llGiveInventory(string destination, string inventory); |
211 | void llGiveInventoryList(string destination, string category, LSL_List inventory); | 211 | void llGiveInventoryList(string destination, string category, LSL_List inventory); |
212 | void llGiveMoney(string destination, int amount); | 212 | LSL_Integer llGiveMoney(string destination, int amount); |
213 | LSL_String llTransferLindenDollars(string destination, int amount); | 213 | LSL_String llTransferLindenDollars(string destination, int amount); |
214 | void llGodLikeRezObject(string inventory, LSL_Vector pos); | 214 | void llGodLikeRezObject(string inventory, LSL_Vector pos); |
215 | LSL_Float llGround(LSL_Vector offset); | 215 | LSL_Float llGround(LSL_Vector offset); |
@@ -344,7 +344,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
344 | void llSetDamage(double damage); | 344 | void llSetDamage(double damage); |
345 | void llSetForce(LSL_Vector force, int local); | 345 | void llSetForce(LSL_Vector force, int local); |
346 | void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local); | 346 | void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local); |
347 | void llSetVelocity(LSL_Vector velocity, int local); | ||
348 | void llSetAngularVelocity(LSL_Vector angularVelocity, int local); | 347 | void llSetAngularVelocity(LSL_Vector angularVelocity, int local); |
349 | void llSetHoverHeight(double height, int water, double tau); | 348 | void llSetHoverHeight(double height, int water, double tau); |
350 | void llSetInventoryPermMask(string item, int mask, int value); | 349 | void llSetInventoryPermMask(string item, int mask, int value); |
@@ -362,11 +361,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
362 | void llSetParcelMusicURL(string url); | 361 | void llSetParcelMusicURL(string url); |
363 | void llSetPayPrice(int price, LSL_List quick_pay_buttons); | 362 | void llSetPayPrice(int price, LSL_List quick_pay_buttons); |
364 | void llSetPos(LSL_Vector pos); | 363 | void llSetPos(LSL_Vector pos); |
364 | LSL_Integer llSetRegionPos(LSL_Vector pos); | ||
365 | LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); | 365 | LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules); |
366 | void llSetPrimitiveParams(LSL_List rules); | 366 | void llSetPrimitiveParams(LSL_List rules); |
367 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); | 367 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); |
368 | void llSetPrimURL(string url); | 368 | void llSetPrimURL(string url); |
369 | LSL_Integer llSetRegionPos(LSL_Vector pos); | ||
370 | void llSetRemoteScriptAccessPin(int pin); | 369 | void llSetRemoteScriptAccessPin(int pin); |
371 | void llSetRot(LSL_Rotation rot); | 370 | void llSetRot(LSL_Rotation rot); |
372 | void llSetScale(LSL_Vector scale); | 371 | void llSetScale(LSL_Vector scale); |
@@ -429,10 +428,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
429 | LSL_Vector llWind(LSL_Vector offset); | 428 | LSL_Vector llWind(LSL_Vector offset); |
430 | LSL_String llXorBase64Strings(string str1, string str2); | 429 | LSL_String llXorBase64Strings(string str1, string str2); |
431 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 430 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
432 | void print(string str); | 431 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); |
432 | void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); | ||
433 | 433 | ||
434 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); | 434 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); |
435 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); | 435 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); |
436 | LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 436 | LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
437 | LSL_List llGetPhysicsMaterial(); | ||
438 | void llSetAnimationOverride(LSL_String animState, LSL_String anim); | ||
439 | void llResetAnimationOverride(LSL_String anim_state); | ||
440 | LSL_String llGetAnimationOverride(LSL_String anim_state); | ||
441 | LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers); | ||
442 | LSL_List llJson2List(LSL_String json); | ||
443 | LSL_String llList2Json(LSL_String type, LSL_List values); | ||
444 | LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value); | ||
445 | LSL_String llJsonValueType(LSL_String json, LSL_List specifiers); | ||
437 | } | 446 | } |
438 | } | 447 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 6259b76..ddd7630 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -144,7 +144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
144 | // Avatar Info Commands | 144 | // Avatar Info Commands |
145 | string osGetAgentIP(string agent); | 145 | string osGetAgentIP(string agent); |
146 | LSL_List osGetAgents(); | 146 | LSL_List osGetAgents(); |
147 | 147 | ||
148 | // Teleport commands | 148 | // Teleport commands |
149 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 149 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
150 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 150 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
@@ -261,7 +261,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
261 | string osGetSimulatorVersion(); | 261 | string osGetSimulatorVersion(); |
262 | LSL_Integer osCheckODE(); | 262 | LSL_Integer osCheckODE(); |
263 | string osGetPhysicsEngineType(); | 263 | string osGetPhysicsEngineType(); |
264 | Object osParseJSONNew(string JSON); | ||
265 | Hashtable osParseJSON(string JSON); | 264 | Hashtable osParseJSON(string JSON); |
266 | 265 | ||
267 | void osMessageObject(key objectUUID,string message); | 266 | void osMessageObject(key objectUUID,string message); |
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 ce17ed0..1cc2cfb 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; |
@@ -133,6 +134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
133 | return (eventFlags); | 134 | return (eventFlags); |
134 | } | 135 | } |
135 | 136 | ||
137 | [DebuggerNonUserCode] | ||
136 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 138 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
137 | { | 139 | { |
138 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 140 | // 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 9aecea2..158acc6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -57,7 +57,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
57 | public const int ACTIVE = 2; | 57 | public const int ACTIVE = 2; |
58 | public const int PASSIVE = 4; | 58 | public const int PASSIVE = 4; |
59 | public const int SCRIPTED = 8; | 59 | public const int SCRIPTED = 8; |
60 | public const int OS_NPC = 0x01000000; | ||
61 | 60 | ||
62 | public const int CONTROL_FWD = 1; | 61 | public const int CONTROL_FWD = 1; |
63 | public const int CONTROL_BACK = 2; | 62 | public const int CONTROL_BACK = 2; |
@@ -82,6 +81,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
82 | public const int PERMISSION_CHANGE_PERMISSIONS = 512; | 81 | public const int PERMISSION_CHANGE_PERMISSIONS = 512; |
83 | public const int PERMISSION_TRACK_CAMERA = 1024; | 82 | public const int PERMISSION_TRACK_CAMERA = 1024; |
84 | public const int PERMISSION_CONTROL_CAMERA = 2048; | 83 | public const int PERMISSION_CONTROL_CAMERA = 2048; |
84 | public const int PERMISSION_TELEPORT = 4096; | ||
85 | public const int PERMISSION_OVERRIDE_ANIMATIONS = 0x8000; | ||
85 | 86 | ||
86 | public const int AGENT_FLYING = 1; | 87 | public const int AGENT_FLYING = 1; |
87 | public const int AGENT_ATTACHMENTS = 2; | 88 | public const int AGENT_ATTACHMENTS = 2; |
@@ -96,6 +97,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
96 | public const int AGENT_CROUCHING = 1024; | 97 | public const int AGENT_CROUCHING = 1024; |
97 | public const int AGENT_BUSY = 2048; | 98 | public const int AGENT_BUSY = 2048; |
98 | public const int AGENT_ALWAYS_RUN = 4096; | 99 | public const int AGENT_ALWAYS_RUN = 4096; |
100 | public const int AGENT_MALE = 8192; | ||
99 | 101 | ||
100 | //Particle Systems | 102 | //Particle Systems |
101 | public const int PSYS_PART_INTERP_COLOR_MASK = 1; | 103 | public const int PSYS_PART_INTERP_COLOR_MASK = 1; |
@@ -353,6 +355,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
353 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART | 355 | public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART |
354 | public const int CHANGED_MEDIA = 2048; | 356 | public const int CHANGED_MEDIA = 2048; |
355 | public const int CHANGED_ANIMATION = 16384; | 357 | public const int CHANGED_ANIMATION = 16384; |
358 | public const int CHANGED_POSITION = 32768; | ||
356 | public const int TYPE_INVALID = 0; | 359 | public const int TYPE_INVALID = 0; |
357 | public const int TYPE_INTEGER = 1; | 360 | public const int TYPE_INTEGER = 1; |
358 | public const int TYPE_FLOAT = 2; | 361 | public const int TYPE_FLOAT = 2; |
@@ -708,7 +711,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
708 | public const int FRICTION = 2; | 711 | public const int FRICTION = 2; |
709 | public const int RESTITUTION = 4; | 712 | public const int RESTITUTION = 4; |
710 | public const int GRAVITY_MULTIPLIER = 8; | 713 | public const int GRAVITY_MULTIPLIER = 8; |
711 | 714 | ||
712 | // extra constants for llSetPrimMediaParams | 715 | // extra constants for llSetPrimMediaParams |
713 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); | 716 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); |
714 | public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000); | 717 | public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000); |
@@ -795,6 +798,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
795 | public const int KFM_CMD_STOP = 1; | 798 | public const int KFM_CMD_STOP = 1; |
796 | public const int KFM_CMD_PAUSE = 2; | 799 | public const int KFM_CMD_PAUSE = 2; |
797 | 800 | ||
801 | public const string JSON_ARRAY = "JSON_ARRAY"; | ||
802 | public const string JSON_OBJECT = "JSON_OBJECT"; | ||
803 | public const string JSON_INVALID = "JSON_INVALID"; | ||
804 | public const string JSON_NUMBER = "JSON_NUMBER"; | ||
805 | public const string JSON_STRING = "JSON_STRING"; | ||
806 | public const string JSON_TRUE = "JSON_TRUE"; | ||
807 | public const string JSON_FALSE = "JSON_FALSE"; | ||
808 | public const string JSON_NULL = "JSON_NULL"; | ||
809 | public const string JSON_APPEND = "JSON_APPEND"; | ||
810 | |||
798 | /// <summary> | 811 | /// <summary> |
799 | /// process name parameter as regex | 812 | /// process name parameter as regex |
800 | /// </summary> | 813 | /// </summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 35aaf01..2745637 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -314,6 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
314 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 315 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
315 | } | 316 | } |
316 | 317 | ||
318 | [DebuggerNonUserCode] | ||
317 | public void llDie() | 319 | public void llDie() |
318 | { | 320 | { |
319 | m_LSL_Functions.llDie(); | 321 | m_LSL_Functions.llDie(); |
@@ -479,6 +481,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
479 | return m_LSL_Functions.llGetFreeMemory(); | 481 | return m_LSL_Functions.llGetFreeMemory(); |
480 | } | 482 | } |
481 | 483 | ||
484 | public LSL_Integer llGetUsedMemory() | ||
485 | { | ||
486 | return m_LSL_Functions.llGetUsedMemory(); | ||
487 | } | ||
488 | |||
482 | public LSL_Integer llGetFreeURLs() | 489 | public LSL_Integer llGetFreeURLs() |
483 | { | 490 | { |
484 | return m_LSL_Functions.llGetFreeURLs(); | 491 | return m_LSL_Functions.llGetFreeURLs(); |
@@ -559,11 +566,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
559 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | 566 | return m_LSL_Functions.llGetLinkNumberOfSides(link); |
560 | } | 567 | } |
561 | 568 | ||
562 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
563 | { | ||
564 | m_LSL_Functions.llSetKeyframedMotion(frames, options); | ||
565 | } | ||
566 | |||
567 | public LSL_Integer llGetListEntryType(LSL_List src, int index) | 569 | public LSL_Integer llGetListEntryType(LSL_List src, int index) |
568 | { | 570 | { |
569 | return m_LSL_Functions.llGetListEntryType(src, index); | 571 | return m_LSL_Functions.llGetListEntryType(src, index); |
@@ -859,11 +861,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
859 | return m_LSL_Functions.llGetUnixTime(); | 861 | return m_LSL_Functions.llGetUnixTime(); |
860 | } | 862 | } |
861 | 863 | ||
862 | public LSL_Integer llGetUsedMemory() | ||
863 | { | ||
864 | return m_LSL_Functions.llGetUsedMemory(); | ||
865 | } | ||
866 | |||
867 | public LSL_Vector llGetVel() | 864 | public LSL_Vector llGetVel() |
868 | { | 865 | { |
869 | return m_LSL_Functions.llGetVel(); | 866 | return m_LSL_Functions.llGetVel(); |
@@ -884,9 +881,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
884 | m_LSL_Functions.llGiveInventoryList(destination, category, inventory); | 881 | m_LSL_Functions.llGiveInventoryList(destination, category, inventory); |
885 | } | 882 | } |
886 | 883 | ||
887 | public void llGiveMoney(string destination, int amount) | 884 | public LSL_Integer llGiveMoney(string destination, int amount) |
888 | { | 885 | { |
889 | m_LSL_Functions.llGiveMoney(destination, amount); | 886 | return m_LSL_Functions.llGiveMoney(destination, amount); |
890 | } | 887 | } |
891 | 888 | ||
892 | public LSL_String llTransferLindenDollars(string destination, int amount) | 889 | public LSL_String llTransferLindenDollars(string destination, int amount) |
@@ -1558,11 +1555,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1558 | m_LSL_Functions.llSetForceAndTorque(force, torque, local); | 1555 | m_LSL_Functions.llSetForceAndTorque(force, torque, local); |
1559 | } | 1556 | } |
1560 | 1557 | ||
1561 | public void llSetVelocity(LSL_Vector force, int local) | ||
1562 | { | ||
1563 | m_LSL_Functions.llSetVelocity(force, local); | ||
1564 | } | ||
1565 | |||
1566 | public void llSetAngularVelocity(LSL_Vector force, int local) | 1558 | public void llSetAngularVelocity(LSL_Vector force, int local) |
1567 | { | 1559 | { |
1568 | m_LSL_Functions.llSetAngularVelocity(force, local); | 1560 | m_LSL_Functions.llSetAngularVelocity(force, local); |
@@ -1643,6 +1635,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1643 | m_LSL_Functions.llSetPos(pos); | 1635 | m_LSL_Functions.llSetPos(pos); |
1644 | } | 1636 | } |
1645 | 1637 | ||
1638 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1639 | { | ||
1640 | return m_LSL_Functions.llSetRegionPos(pos); | ||
1641 | } | ||
1642 | |||
1646 | public void llSetPrimitiveParams(LSL_List rules) | 1643 | public void llSetPrimitiveParams(LSL_List rules) |
1647 | { | 1644 | { |
1648 | m_LSL_Functions.llSetPrimitiveParams(rules); | 1645 | m_LSL_Functions.llSetPrimitiveParams(rules); |
@@ -1658,11 +1655,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1658 | m_LSL_Functions.llSetPrimURL(url); | 1655 | m_LSL_Functions.llSetPrimURL(url); |
1659 | } | 1656 | } |
1660 | 1657 | ||
1661 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1662 | { | ||
1663 | return m_LSL_Functions.llSetRegionPos(pos); | ||
1664 | } | ||
1665 | |||
1666 | public void llSetRemoteScriptAccessPin(int pin) | 1658 | public void llSetRemoteScriptAccessPin(int pin) |
1667 | { | 1659 | { |
1668 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); | 1660 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); |
@@ -2008,9 +2000,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
2008 | return m_LSL_Functions.llClearLinkMedia(link, face); | 2000 | return m_LSL_Functions.llClearLinkMedia(link, face); |
2009 | } | 2001 | } |
2010 | 2002 | ||
2011 | public void print(string str) | 2003 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
2004 | { | ||
2005 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | ||
2006 | } | ||
2007 | |||
2008 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
2009 | { | ||
2010 | m_LSL_Functions.llSetKeyframedMotion(frames, options); | ||
2011 | } | ||
2012 | |||
2013 | public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density) | ||
2014 | { | ||
2015 | m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); | ||
2016 | } | ||
2017 | |||
2018 | public LSL_List llGetPhysicsMaterial() | ||
2019 | { | ||
2020 | return m_LSL_Functions.llGetPhysicsMaterial(); | ||
2021 | } | ||
2022 | |||
2023 | public void llSetAnimationOverride(LSL_String animState, LSL_String anim) | ||
2024 | { | ||
2025 | m_LSL_Functions.llSetAnimationOverride(animState, anim); | ||
2026 | } | ||
2027 | |||
2028 | public void llResetAnimationOverride(LSL_String anim_state) | ||
2029 | { | ||
2030 | m_LSL_Functions.llResetAnimationOverride(anim_state); | ||
2031 | } | ||
2032 | |||
2033 | public LSL_String llGetAnimationOverride(LSL_String anim_state) | ||
2034 | { | ||
2035 | return m_LSL_Functions.llGetAnimationOverride(anim_state); | ||
2036 | } | ||
2037 | |||
2038 | public LSL_String llJsonGetValue(LSL_String json, LSL_List specifiers) | ||
2039 | { | ||
2040 | return m_LSL_Functions.llJsonGetValue(json, specifiers); | ||
2041 | } | ||
2042 | |||
2043 | public LSL_List llJson2List(LSL_String json) | ||
2044 | { | ||
2045 | return m_LSL_Functions.llJson2List(json); | ||
2046 | } | ||
2047 | |||
2048 | public LSL_String llList2Json(LSL_String type, LSL_List values) | ||
2049 | { | ||
2050 | return m_LSL_Functions.llList2Json(type, values); | ||
2051 | } | ||
2052 | |||
2053 | public LSL_String llJsonSetValue(LSL_String json, LSL_List specifiers, LSL_String value) | ||
2054 | { | ||
2055 | return m_LSL_Functions.llJsonSetValue(json, specifiers, value); | ||
2056 | } | ||
2057 | |||
2058 | public LSL_String llJsonValueType(LSL_String json, LSL_List specifiers) | ||
2012 | { | 2059 | { |
2013 | m_LSL_Functions.print(str); | 2060 | return m_LSL_Functions.llJsonValueType(json, specifiers); |
2014 | } | 2061 | } |
2015 | } | 2062 | } |
2016 | } | 2063 | } |
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/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index a60f381..5fdbf9d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -440,11 +440,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
440 | return m_OSSL_Functions.osParseJSON(JSON); | 440 | return m_OSSL_Functions.osParseJSON(JSON); |
441 | } | 441 | } |
442 | 442 | ||
443 | public Object osParseJSONNew(string JSON) | ||
444 | { | ||
445 | return m_OSSL_Functions.osParseJSONNew(JSON); | ||
446 | } | ||
447 | |||
448 | public void osMessageObject(key objectUUID,string message) | 443 | public void osMessageObject(key objectUUID,string message) |
449 | { | 444 | { |
450 | m_OSSL_Functions.osMessageObject(objectUUID,message); | 445 | m_OSSL_Functions.osMessageObject(objectUUID,message); |
@@ -744,14 +739,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
744 | if (Position.y > ((int)Constants.RegionSize - 1)) | 739 | if (Position.y > ((int)Constants.RegionSize - 1)) |
745 | Position.y = ((int)Constants.RegionSize - 1); | 740 | Position.y = ((int)Constants.RegionSize - 1); |
746 | */ | 741 | */ |
742 | <<<<<<< HEAD | ||
747 | if (Position.z > Constants.RegionHeight) | 743 | if (Position.z > Constants.RegionHeight) |
748 | Position.z = Constants.RegionHeight; | 744 | Position.z = Constants.RegionHeight; |
745 | ======= | ||
746 | >>>>>>> avn/ubitvar | ||
749 | if (Position.x < 0) | 747 | if (Position.x < 0) |
750 | Position.x = 0; | 748 | Position.x = 0; |
751 | if (Position.y < 0) | 749 | if (Position.y < 0) |
752 | Position.y = 0; | 750 | Position.y = 0; |
753 | if (Position.z < 0) | 751 | if (Position.z < 0) |
754 | Position.z = 0; | 752 | Position.z = 0; |
753 | if (Position.z > Constants.RegionHeight) | ||
754 | Position.z = Constants.RegionHeight; | ||
755 | prim.OSSL.llSetPos(Position); | 755 | prim.OSSL.llSetPos(Position); |
756 | } | 756 | } |
757 | 757 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index edbbc2a..b138da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index e02d35e..e44a106 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -35,6 +35,7 @@ using OpenMetaverse; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.CoreModules; | 36 | using OpenSim.Region.CoreModules; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | 40 | ||
40 | namespace OpenSim.Region.ScriptEngine.Shared | 41 | namespace OpenSim.Region.ScriptEngine.Shared |
@@ -120,6 +121,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
120 | Type = 0; | 121 | Type = 0; |
121 | Velocity = new LSL_Types.Vector3(); | 122 | Velocity = new LSL_Types.Vector3(); |
122 | initializeSurfaceTouch(); | 123 | initializeSurfaceTouch(); |
124 | Country = String.Empty; | ||
123 | } | 125 | } |
124 | 126 | ||
125 | public UUID Key; | 127 | public UUID Key; |
@@ -151,6 +153,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
151 | private int touchFace; | 153 | private int touchFace; |
152 | public int TouchFace { get { return touchFace; } } | 154 | public int TouchFace { get { return touchFace; } } |
153 | 155 | ||
156 | public string Country; | ||
157 | |||
154 | // This can be done in two places including the constructor | 158 | // This can be done in two places including the constructor |
155 | // so be carefull what gets added here | 159 | // so be carefull what gets added here |
156 | private void initializeSurfaceTouch() | 160 | private void initializeSurfaceTouch() |
@@ -198,6 +202,10 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
198 | return; | 202 | return; |
199 | 203 | ||
200 | Name = presence.Firstname + " " + presence.Lastname; | 204 | Name = presence.Firstname + " " + presence.Lastname; |
205 | UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, Key); | ||
206 | if (account != null) | ||
207 | Country = account.UserCountry; | ||
208 | |||
201 | Owner = Key; | 209 | Owner = Key; |
202 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); | 210 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); |
203 | Rotation = new LSL_Types.Quaternion( | 211 | Rotation = new LSL_Types.Quaternion( |
@@ -207,22 +215,27 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
207 | presence.Rotation.W); | 215 | presence.Rotation.W); |
208 | Velocity = new LSL_Types.Vector3(presence.Velocity); | 216 | Velocity = new LSL_Types.Vector3(presence.Velocity); |
209 | 217 | ||
210 | if (presence.PresenceType != PresenceType.Npc) | 218 | Type = 0x01; // Avatar |
211 | { | 219 | if (presence.PresenceType == PresenceType.Npc) |
212 | Type = AGENT; | 220 | Type = 0x20; |
213 | } | 221 | |
214 | else | 222 | // Cope Impl. We don't use OS_NPC. |
215 | { | 223 | //if (presence.PresenceType != PresenceType.Npc) |
216 | Type = OS_NPC; | 224 | //{ |
217 | 225 | // Type = AGENT; | |
218 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 226 | //} |
219 | INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); | 227 | //else |
220 | 228 | //{ | |
221 | if (npcData.SenseAsAgent) | 229 | // Type = OS_NPC; |
222 | { | 230 | |
223 | Type |= AGENT; | 231 | // INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
224 | } | 232 | // INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); |
225 | } | 233 | |
234 | // if (npcData.SenseAsAgent) | ||
235 | // { | ||
236 | // Type |= AGENT; | ||
237 | // } | ||
238 | //} | ||
226 | 239 | ||
227 | if (presence.Velocity != Vector3.Zero) | 240 | if (presence.Velocity != Vector3.Zero) |
228 | Type |= ACTIVE; | 241 | Type |= ACTIVE; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index fa6e6fc..49df5e7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Runtime.Remoting; | 35 | using System.Runtime.Remoting; |
35 | using System.Runtime.Remoting.Lifetime; | 36 | using System.Runtime.Remoting.Lifetime; |
@@ -186,13 +187,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
186 | 187 | ||
187 | public UUID ItemID { get; private set; } | 188 | public UUID ItemID { get; private set; } |
188 | 189 | ||
189 | public UUID ObjectID { get { return Part.UUID; } } | 190 | public UUID ObjectID { get; private set; } |
190 | 191 | ||
191 | public uint LocalID { get { return Part.LocalId; } } | 192 | public uint LocalID { get; private set; } |
192 | 193 | ||
193 | public UUID RootObjectID { get { return Part.ParentGroup.UUID; } } | 194 | public UUID RootObjectID { get; private set; } |
194 | 195 | ||
195 | public uint RootLocalID { get { return Part.ParentGroup.LocalId; } } | 196 | public uint RootLocalID { get; private set; } |
196 | 197 | ||
197 | public UUID AssetID { get; private set; } | 198 | public UUID AssetID { get; private set; } |
198 | 199 | ||
@@ -251,13 +252,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
251 | ItemID = ScriptTask.ItemID; | 252 | ItemID = ScriptTask.ItemID; |
252 | AssetID = ScriptTask.AssetID; | 253 | AssetID = ScriptTask.AssetID; |
253 | } | 254 | } |
255 | LocalID = part.LocalId; | ||
254 | 256 | ||
255 | PrimName = part.ParentGroup.Name; | 257 | PrimName = part.ParentGroup.Name; |
256 | StartParam = startParam; | 258 | StartParam = startParam; |
257 | m_MaxScriptQueue = maxScriptQueue; | 259 | m_MaxScriptQueue = maxScriptQueue; |
258 | m_postOnRez = postOnRez; | 260 | m_postOnRez = postOnRez; |
259 | m_AttachedAvatar = Part.ParentGroup.AttachedAvatar; | 261 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; |
260 | m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID; | 262 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; |
261 | 263 | ||
262 | m_SaveState = StatePersistedHere; | 264 | m_SaveState = StatePersistedHere; |
263 | 265 | ||
@@ -456,27 +458,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
456 | PostEvent(new EventParams("attach", | 458 | PostEvent(new EventParams("attach", |
457 | new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); | 459 | new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); |
458 | } | 460 | } |
461 | |||
459 | } | 462 | } |
460 | } | 463 | } |
461 | 464 | ||
462 | private void ReleaseControls() | 465 | private void ReleaseControls() |
463 | { | 466 | { |
464 | int permsMask; | 467 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
465 | UUID permsGranter; | 468 | |
466 | lock (Part.TaskInventory) | 469 | if (part != null) |
467 | { | 470 | { |
468 | if (!Part.TaskInventory.ContainsKey(ItemID)) | 471 | int permsMask; |
472 | UUID permsGranter; | ||
473 | part.TaskInventory.LockItemsForRead(true); | ||
474 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
475 | { | ||
476 | part.TaskInventory.LockItemsForRead(false); | ||
469 | return; | 477 | return; |
478 | } | ||
479 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
480 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
481 | part.TaskInventory.LockItemsForRead(false); | ||
470 | 482 | ||
471 | permsGranter = Part.TaskInventory[ItemID].PermsGranter; | 483 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
472 | permsMask = Part.TaskInventory[ItemID].PermsMask; | 484 | { |
473 | } | 485 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); |
474 | 486 | if (presence != null) | |
475 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 487 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); |
476 | { | 488 | } |
477 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); | ||
478 | if (presence != null) | ||
479 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); | ||
480 | } | 489 | } |
481 | } | 490 | } |
482 | 491 | ||
@@ -639,11 +648,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | return true; | 648 | return true; |
640 | } | 649 | } |
641 | 650 | ||
651 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
642 | public void SetState(string state) | 652 | public void SetState(string state) |
643 | { | 653 | { |
644 | if (state == State) | 654 | if (state == State) |
645 | return; | 655 | return; |
646 | 656 | ||
657 | <<<<<<< HEAD | ||
647 | EventParams lastTimerEv = null; | 658 | EventParams lastTimerEv = null; |
648 | 659 | ||
649 | lock (EventQueue) | 660 | lock (EventQueue) |
@@ -671,6 +682,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
671 | m_StateChangeInProgress = true; | 682 | m_StateChangeInProgress = true; |
672 | } | 683 | } |
673 | 684 | ||
685 | ======= | ||
686 | PostEvent(new EventParams("state_exit", new Object[0], | ||
687 | new DetectParams[0])); | ||
688 | PostEvent(new EventParams("state", new Object[] { state }, | ||
689 | new DetectParams[0])); | ||
690 | PostEvent(new EventParams("state_entry", new Object[0], | ||
691 | new DetectParams[0])); | ||
692 | |||
693 | >>>>>>> avn/ubitvar | ||
674 | throw new EventAbortException(); | 694 | throw new EventAbortException(); |
675 | } | 695 | } |
676 | 696 | ||
@@ -764,14 +784,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
764 | /// <returns></returns> | 784 | /// <returns></returns> |
765 | public object EventProcessor() | 785 | public object EventProcessor() |
766 | { | 786 | { |
787 | EventParams data = null; | ||
767 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 788 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
768 | if (!Running) | 789 | if (!Running) |
769 | return 0; | 790 | return 0; |
770 | 791 | ||
771 | lock (m_Script) | ||
772 | { | ||
773 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 792 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
774 | 793 | ||
794 | <<<<<<< HEAD | ||
775 | if (Suspended) | 795 | if (Suspended) |
776 | return 0; | 796 | return 0; |
777 | 797 | ||
@@ -797,6 +817,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
797 | lock (EventQueue) | 817 | lock (EventQueue) |
798 | { | 818 | { |
799 | data = (EventParams)EventQueue.Dequeue(); | 819 | data = (EventParams)EventQueue.Dequeue(); |
820 | ======= | ||
821 | if (Suspended) | ||
822 | return 0; | ||
823 | |||
824 | lock (EventQueue) | ||
825 | { | ||
826 | data = (EventParams) EventQueue.Dequeue(); | ||
827 | >>>>>>> avn/ubitvar | ||
800 | if (data == null) // Shouldn't happen | 828 | if (data == null) // Shouldn't happen |
801 | { | 829 | { |
802 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 830 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
@@ -821,6 +849,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
821 | m_CollisionInQueue = false; | 849 | m_CollisionInQueue = false; |
822 | } | 850 | } |
823 | 851 | ||
852 | <<<<<<< HEAD | ||
824 | if (DebugLevel >= 2) | 853 | if (DebugLevel >= 2) |
825 | m_log.DebugFormat( | 854 | m_log.DebugFormat( |
826 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | 855 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", |
@@ -850,6 +879,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
850 | Part.ParentGroup.UUID, | 879 | Part.ParentGroup.UUID, |
851 | Part.AbsolutePosition, | 880 | Part.AbsolutePosition, |
852 | Part.ParentGroup.Scene.Name); | 881 | Part.ParentGroup.Scene.Name); |
882 | ======= | ||
883 | lock(m_Script) | ||
884 | { | ||
885 | |||
886 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | ||
887 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | ||
888 | |||
889 | if (DebugLevel >= 2) | ||
890 | m_log.DebugFormat( | ||
891 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | ||
892 | data.EventName, | ||
893 | ScriptName, | ||
894 | part.Name, | ||
895 | part.LocalId, | ||
896 | part.ParentGroup.Name, | ||
897 | part.ParentGroup.UUID, | ||
898 | part.AbsolutePosition, | ||
899 | part.ParentGroup.Scene.Name); | ||
900 | >>>>>>> avn/ubitvar | ||
853 | 901 | ||
854 | AsyncCommandManager.StateChange(Engine, | 902 | AsyncCommandManager.StateChange(Engine, |
855 | LocalID, ItemID); | 903 | LocalID, ItemID); |
@@ -867,7 +915,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
867 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | 915 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
868 | // PrimName, ScriptName, data.EventName, State); | 916 | // PrimName, ScriptName, data.EventName, State); |
869 | 917 | ||
918 | <<<<<<< HEAD | ||
870 | try | 919 | try |
920 | ======= | ||
921 | if (DebugLevel >= 1) | ||
922 | m_log.DebugFormat( | ||
923 | "[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | ||
924 | State, | ||
925 | ScriptName, | ||
926 | part.Name, | ||
927 | part.LocalId, | ||
928 | part.ParentGroup.Name, | ||
929 | part.ParentGroup.UUID, | ||
930 | part.AbsolutePosition, | ||
931 | part.ParentGroup.Scene.Name); | ||
932 | |||
933 | AsyncCommandManager.RemoveScript(Engine, | ||
934 | LocalID, ItemID); | ||
935 | |||
936 | if (part != null) | ||
937 | { | ||
938 | part.SetScriptEvents(ItemID, | ||
939 | (int)m_Script.GetStateEventFlags(State)); | ||
940 | } | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | if (Engine.World.PipeEventsForScript(LocalID) || | ||
945 | data.EventName == "control") // Don't freeze avies! | ||
946 | >>>>>>> avn/ubitvar | ||
871 | { | 947 | { |
872 | m_CurrentEvent = data.EventName; | 948 | m_CurrentEvent = data.EventName; |
873 | m_EventStart = DateTime.Now; | 949 | m_EventStart = DateTime.Now; |
@@ -905,6 +981,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
905 | && !(e.InnerException is ScriptCoopStopException))) | 981 | && !(e.InnerException is ScriptCoopStopException))) |
906 | && !(e is ThreadAbortException)) | 982 | && !(e is ThreadAbortException)) |
907 | { | 983 | { |
984 | <<<<<<< HEAD | ||
908 | try | 985 | try |
909 | { | 986 | { |
910 | // DISPLAY ERROR INWORLD | 987 | // DISPLAY ERROR INWORLD |
@@ -927,9 +1004,78 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
927 | Part.AbsolutePosition, | 1004 | Part.AbsolutePosition, |
928 | Part.ParentGroup.Scene.Name), | 1005 | Part.ParentGroup.Scene.Name), |
929 | e); | 1006 | e); |
1007 | ======= | ||
1008 | // m_log.DebugFormat( | ||
1009 | // "[SCRIPT] Exception in script {0} {1}: {2}{3}", | ||
1010 | // ScriptName, ItemID, e.Message, e.StackTrace); | ||
1011 | |||
1012 | m_InEvent = false; | ||
1013 | m_CurrentEvent = String.Empty; | ||
1014 | |||
1015 | if ((!(e is TargetInvocationException) | ||
1016 | || (!(e.InnerException is SelfDeleteException) | ||
1017 | && !(e.InnerException is ScriptDeleteException) | ||
1018 | && !(e.InnerException is ScriptCoopStopException))) | ||
1019 | && !(e is ThreadAbortException)) | ||
1020 | { | ||
1021 | try | ||
1022 | { | ||
1023 | // DISPLAY ERROR INWORLD | ||
1024 | string text = FormatException(e); | ||
1025 | |||
1026 | if (text.Length > 1000) | ||
1027 | text = text.Substring(0, 1000); | ||
1028 | Engine.World.SimChat(Utils.StringToBytes(text), | ||
1029 | ChatTypeEnum.DebugChannel, 2147483647, | ||
1030 | part.AbsolutePosition, | ||
1031 | part.Name, part.UUID, false); | ||
1032 | |||
1033 | |||
1034 | m_log.DebugFormat( | ||
1035 | "[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}", | ||
1036 | ScriptName, | ||
1037 | PrimName, | ||
1038 | part.UUID, | ||
1039 | part.AbsolutePosition, | ||
1040 | part.ParentGroup.Scene.Name, | ||
1041 | text.Replace("\n", "\\n"), | ||
1042 | e.InnerException); | ||
1043 | } | ||
1044 | catch (Exception) | ||
1045 | { | ||
1046 | } | ||
1047 | // catch (Exception e2) // LEGIT: User Scripting | ||
1048 | // { | ||
1049 | // m_log.Error("[SCRIPT]: "+ | ||
1050 | // "Error displaying error in-world: " + | ||
1051 | // e2.ToString()); | ||
1052 | // m_log.Error("[SCRIPT]: " + | ||
1053 | // "Errormessage: Error compiling script:\r\n" + | ||
1054 | // e.ToString()); | ||
1055 | // } | ||
1056 | } | ||
1057 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
1058 | { | ||
1059 | m_InSelfDelete = true; | ||
1060 | if (part != null) | ||
1061 | Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
1062 | >>>>>>> avn/ubitvar | ||
930 | } | 1063 | } |
931 | catch (Exception) | 1064 | catch (Exception) |
932 | { | 1065 | { |
1066 | <<<<<<< HEAD | ||
1067 | ======= | ||
1068 | m_InSelfDelete = true; | ||
1069 | if (part != null) | ||
1070 | part.Inventory.RemoveInventoryItem(ItemID); | ||
1071 | } | ||
1072 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) | ||
1073 | { | ||
1074 | if (DebugLevel >= 1) | ||
1075 | m_log.DebugFormat( | ||
1076 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", | ||
1077 | PrimName, ScriptName, data.EventName, State); | ||
1078 | >>>>>>> avn/ubitvar | ||
933 | } | 1079 | } |
934 | // catch (Exception e2) // LEGIT: User Scripting | 1080 | // catch (Exception e2) // LEGIT: User Scripting |
935 | // { | 1081 | // { |
@@ -1012,15 +1158,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1012 | ReleaseControls(); | 1158 | ReleaseControls(); |
1013 | 1159 | ||
1014 | Stop(timeout); | 1160 | Stop(timeout); |
1015 | Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 1161 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
1016 | Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 1162 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
1163 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | ||
1164 | part.CollisionSound = UUID.Zero; | ||
1017 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 1165 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
1018 | EventQueue.Clear(); | 1166 | EventQueue.Clear(); |
1019 | m_Script.ResetVars(); | 1167 | m_Script.ResetVars(); |
1020 | StartParam = 0; | 1168 | StartParam = 0; |
1021 | State = "default"; | 1169 | State = "default"; |
1022 | 1170 | ||
1023 | Part.SetScriptEvents(ItemID, | 1171 | part.SetScriptEvents(ItemID, |
1024 | (int)m_Script.GetStateEventFlags(State)); | 1172 | (int)m_Script.GetStateEventFlags(State)); |
1025 | if (running) | 1173 | if (running) |
1026 | Start(); | 1174 | Start(); |
@@ -1031,6 +1179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1031 | new Object[0], new DetectParams[0])); | 1179 | new Object[0], new DetectParams[0])); |
1032 | } | 1180 | } |
1033 | 1181 | ||
1182 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
1034 | public void ApiResetScript() | 1183 | public void ApiResetScript() |
1035 | { | 1184 | { |
1036 | // bool running = Running; | 1185 | // bool running = Running; |
@@ -1039,8 +1188,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1039 | ReleaseControls(); | 1188 | ReleaseControls(); |
1040 | 1189 | ||
1041 | m_Script.ResetVars(); | 1190 | m_Script.ResetVars(); |
1042 | Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 1191 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
1043 | Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 1192 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
1193 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | ||
1194 | part.CollisionSound = UUID.Zero; | ||
1044 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 1195 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
1045 | 1196 | ||
1046 | EventQueue.Clear(); | 1197 | EventQueue.Clear(); |
@@ -1049,7 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1049 | StartParam = 0; | 1200 | StartParam = 0; |
1050 | State = "default"; | 1201 | State = "default"; |
1051 | 1202 | ||
1052 | Part.SetScriptEvents(ItemID, | 1203 | part.SetScriptEvents(ItemID, |
1053 | (int)m_Script.GetStateEventFlags(State)); | 1204 | (int)m_Script.GetStateEventFlags(State)); |
1054 | 1205 | ||
1055 | if (m_CurrentEvent != "state_entry" || oldState != "default") | 1206 | if (m_CurrentEvent != "state_entry" || oldState != "default") |
@@ -1063,10 +1214,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1063 | 1214 | ||
1064 | public Dictionary<string, object> GetVars() | 1215 | public Dictionary<string, object> GetVars() |
1065 | { | 1216 | { |
1066 | if (m_Script != null) | 1217 | return m_Script.GetVars(); |
1067 | return m_Script.GetVars(); | ||
1068 | else | ||
1069 | return new Dictionary<string, object>(); | ||
1070 | } | 1218 | } |
1071 | 1219 | ||
1072 | public void SetVars(Dictionary<string, object> vars) | 1220 | public void SetVars(Dictionary<string, object> vars) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 0ca5ff3..885559a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -102,19 +102,31 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
102 | 102 | ||
103 | public override string ToString() | 103 | public override string ToString() |
104 | { | 104 | { |
105 | <<<<<<< HEAD | ||
105 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); | 106 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); |
107 | ======= | ||
108 | string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); | ||
109 | >>>>>>> avn/ubitvar | ||
106 | return s; | 110 | return s; |
107 | } | 111 | } |
108 | 112 | ||
109 | public static explicit operator LSLString(Vector3 vec) | 113 | public static explicit operator LSLString(Vector3 vec) |
110 | { | 114 | { |
115 | <<<<<<< HEAD | ||
111 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 116 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); |
117 | ======= | ||
118 | string s = String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); | ||
119 | >>>>>>> avn/ubitvar | ||
112 | return new LSLString(s); | 120 | return new LSLString(s); |
113 | } | 121 | } |
114 | 122 | ||
115 | public static explicit operator string(Vector3 vec) | 123 | public static explicit operator string(Vector3 vec) |
116 | { | 124 | { |
125 | <<<<<<< HEAD | ||
117 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); | 126 | string s=String.Format(Culture.FormatProvider,"<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); |
127 | ======= | ||
128 | string s = String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); | ||
129 | >>>>>>> avn/ubitvar | ||
118 | return s; | 130 | return s; |
119 | } | 131 | } |
120 | 132 | ||
@@ -414,19 +426,19 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
414 | 426 | ||
415 | public override string ToString() | 427 | public override string ToString() |
416 | { | 428 | { |
417 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); | 429 | string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); |
418 | return st; | 430 | return st; |
419 | } | 431 | } |
420 | 432 | ||
421 | public static explicit operator string(Quaternion r) | 433 | public static explicit operator string(Quaternion r) |
422 | { | 434 | { |
423 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 435 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
424 | return s; | 436 | return s; |
425 | } | 437 | } |
426 | 438 | ||
427 | public static explicit operator LSLString(Quaternion r) | 439 | public static explicit operator LSLString(Quaternion r) |
428 | { | 440 | { |
429 | string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); | 441 | string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); |
430 | return new LSLString(s); | 442 | return new LSLString(s); |
431 | } | 443 | } |
432 | 444 | ||
@@ -537,7 +549,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
537 | else if (o is LSL_Types.LSLFloat) | 549 | else if (o is LSL_Types.LSLFloat) |
538 | size += 8; | 550 | size += 8; |
539 | else if (o is LSL_Types.LSLString) | 551 | else if (o is LSL_Types.LSLString) |
540 | size += ((LSL_Types.LSLString)o).m_string.Length; | 552 | size += ((LSL_Types.LSLString)o).m_string == null ? 0 : ((LSL_Types.LSLString)o).m_string.Length; |
541 | else if (o is LSL_Types.key) | 553 | else if (o is LSL_Types.key) |
542 | size += ((LSL_Types.key)o).value.Length; | 554 | size += ((LSL_Types.key)o).value.Length; |
543 | else if (o is LSL_Types.Vector3) | 555 | else if (o is LSL_Types.Vector3) |
@@ -546,6 +558,8 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
546 | size += 64; | 558 | size += 64; |
547 | else if (o is int) | 559 | else if (o is int) |
548 | size += 4; | 560 | size += 4; |
561 | else if (o is uint) | ||
562 | size += 4; | ||
549 | else if (o is string) | 563 | else if (o is string) |
550 | size += ((string)o).Length; | 564 | size += ((string)o).Length; |
551 | else if (o is float) | 565 | else if (o is float) |
@@ -713,10 +727,17 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
713 | private void ExtendAndAdd(object o) | 727 | private void ExtendAndAdd(object o) |
714 | { | 728 | { |
715 | object[] tmp; | 729 | object[] tmp; |
730 | <<<<<<< HEAD | ||
716 | tmp = new object[Data.Length + 1]; | 731 | tmp = new object[Data.Length + 1]; |
717 | Data.CopyTo(tmp, 0); | 732 | Data.CopyTo(tmp, 0); |
718 | tmp.SetValue(o, tmp.Length - 1); | 733 | tmp.SetValue(o, tmp.Length - 1); |
719 | Data = tmp; | 734 | Data = tmp; |
735 | ======= | ||
736 | tmp = new object[m_data.Length + 1]; | ||
737 | m_data.CopyTo(tmp, 0); | ||
738 | tmp.SetValue(o, tmp.Length - 1); | ||
739 | m_data = tmp; | ||
740 | >>>>>>> avn/ubitvar | ||
720 | } | 741 | } |
721 | 742 | ||
722 | public static list operator +(list a, LSLString s) | 743 | public static list operator +(list a, LSLString s) |
@@ -739,24 +760,16 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
739 | 760 | ||
740 | public static bool operator ==(list a, list b) | 761 | public static bool operator ==(list a, list b) |
741 | { | 762 | { |
742 | int la = -1; | 763 | int la = a.Length; |
743 | int lb = -1; | 764 | int lb = b.Length; |
744 | try { la = a.Length; } | ||
745 | catch (NullReferenceException) { } | ||
746 | try { lb = b.Length; } | ||
747 | catch (NullReferenceException) { } | ||
748 | 765 | ||
749 | return la == lb; | 766 | return la == lb; |
750 | } | 767 | } |
751 | 768 | ||
752 | public static bool operator !=(list a, list b) | 769 | public static bool operator !=(list a, list b) |
753 | { | 770 | { |
754 | int la = -1; | 771 | int la = a.Length; |
755 | int lb = -1; | 772 | int lb = b.Length; |
756 | try { la = a.Length; } | ||
757 | catch (NullReferenceException) { } | ||
758 | try {lb = b.Length;} | ||
759 | catch (NullReferenceException) { } | ||
760 | 773 | ||
761 | return la != lb; | 774 | return la != lb; |
762 | } | 775 | } |
@@ -990,7 +1003,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
990 | ret = Math.Sign(Quaternion.Mag(l) - Quaternion.Mag(r)); | 1003 | ret = Math.Sign(Quaternion.Mag(l) - Quaternion.Mag(r)); |
991 | } | 1004 | } |
992 | 1005 | ||
993 | if (ascending == 0) | 1006 | if (ascending != 1) |
994 | { | 1007 | { |
995 | ret = 0 - ret; | 1008 | ret = 0 - ret; |
996 | } | 1009 | } |
@@ -1023,6 +1036,9 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1023 | stride = 1; | 1036 | stride = 1; |
1024 | } | 1037 | } |
1025 | 1038 | ||
1039 | if ((Data.Length % stride) != 0) | ||
1040 | return new list(ret); | ||
1041 | |||
1026 | // we can optimize here in the case where stride == 1 and the list | 1042 | // we can optimize here in the case where stride == 1 and the list |
1027 | // consists of homogeneous types | 1043 | // consists of homogeneous types |
1028 | 1044 | ||
@@ -1042,7 +1058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1042 | if (homogeneous) | 1058 | if (homogeneous) |
1043 | { | 1059 | { |
1044 | Array.Sort(ret, new HomogeneousComparer()); | 1060 | Array.Sort(ret, new HomogeneousComparer()); |
1045 | if (ascending == 0) | 1061 | if (ascending != 1) |
1046 | { | 1062 | { |
1047 | Array.Reverse(ret); | 1063 | Array.Reverse(ret); |
1048 | } | 1064 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 0ff2da3..ad775ff 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -245,6 +245,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
245 | DetectParams d = new DetectParams(); | 245 | DetectParams d = new DetectParams(); |
246 | d.Key =detobj.keyUUID; | 246 | d.Key =detobj.keyUUID; |
247 | d.Populate(myScriptEngine.World); | 247 | d.Populate(myScriptEngine.World); |
248 | d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part | ||
248 | det.Add(d); | 249 | det.Add(d); |
249 | } | 250 | } |
250 | 251 | ||
@@ -265,6 +266,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
265 | DetectParams d = new DetectParams(); | 266 | DetectParams d = new DetectParams(); |
266 | d.Key =detobj.keyUUID; | 267 | d.Key =detobj.keyUUID; |
267 | d.Populate(myScriptEngine.World); | 268 | d.Populate(myScriptEngine.World); |
269 | d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part | ||
268 | det.Add(d); | 270 | det.Add(d); |
269 | } | 271 | } |
270 | 272 | ||
@@ -284,6 +286,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
284 | DetectParams d = new DetectParams(); | 286 | DetectParams d = new DetectParams(); |
285 | d.Key =detobj.keyUUID; | 287 | d.Key =detobj.keyUUID; |
286 | d.Populate(myScriptEngine.World); | 288 | d.Populate(myScriptEngine.World); |
289 | d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part | ||
287 | det.Add(d); | 290 | det.Add(d); |
288 | } | 291 | } |
289 | 292 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 78d4ee9..466c190 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Globalization; | 32 | using System.Globalization; |
32 | using System.IO; | 33 | using System.IO; |
33 | using System.Linq; | 34 | using System.Linq; |
@@ -161,6 +162,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
161 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 162 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
162 | new Dictionary<UUID, IScriptInstance>(); | 163 | new Dictionary<UUID, IScriptInstance>(); |
163 | 164 | ||
165 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
166 | |||
164 | // Maps the asset ID to the assembly | 167 | // Maps the asset ID to the assembly |
165 | 168 | ||
166 | private Dictionary<UUID, string> m_Assemblies = | 169 | private Dictionary<UUID, string> m_Assemblies = |
@@ -183,6 +186,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
183 | IWorkItemResult m_CurrentCompile = null; | 186 | IWorkItemResult m_CurrentCompile = null; |
184 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); | 187 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); |
185 | 188 | ||
189 | private void lockScriptsForRead(bool locked) | ||
190 | { | ||
191 | if (locked) | ||
192 | { | ||
193 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
194 | { | ||
195 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
196 | m_scriptsLock.ExitReadLock(); | ||
197 | } | ||
198 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
199 | { | ||
200 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
201 | m_scriptsLock.ExitWriteLock(); | ||
202 | } | ||
203 | |||
204 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
205 | { | ||
206 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
207 | if (m_scriptsLock.IsWriteLockHeld) | ||
208 | { | ||
209 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
216 | { | ||
217 | m_scriptsLock.ExitReadLock(); | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | private void lockScriptsForWrite(bool locked) | ||
222 | { | ||
223 | if (locked) | ||
224 | { | ||
225 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
226 | { | ||
227 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
228 | m_scriptsLock.ExitReadLock(); | ||
229 | } | ||
230 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
231 | { | ||
232 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
233 | m_scriptsLock.ExitWriteLock(); | ||
234 | } | ||
235 | |||
236 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
237 | { | ||
238 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
239 | if (m_scriptsLock.IsWriteLockHeld) | ||
240 | { | ||
241 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
248 | { | ||
249 | m_scriptsLock.ExitWriteLock(); | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
186 | private ScriptEngineConsoleCommands m_consoleCommands; | 254 | private ScriptEngineConsoleCommands m_consoleCommands; |
187 | 255 | ||
188 | public string ScriptEngineName | 256 | public string ScriptEngineName |
@@ -714,20 +782,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
714 | { | 782 | { |
715 | if (!m_Enabled) | 783 | if (!m_Enabled) |
716 | return; | 784 | return; |
785 | lockScriptsForRead(true); | ||
717 | 786 | ||
718 | lock (m_Scripts) | 787 | List<IScriptInstance> instancesToDel = new List<IScriptInstance>(m_Scripts.Values); |
719 | { | ||
720 | m_log.InfoFormat( | ||
721 | "[XEngine]: Shutting down {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); | ||
722 | 788 | ||
723 | foreach (IScriptInstance instance in m_Scripts.Values) | 789 | // foreach (IScriptInstance instance in m_Scripts.Values) |
790 | foreach (IScriptInstance instance in instancesToDel) | ||
791 | { | ||
792 | // Force a final state save | ||
793 | // | ||
794 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
724 | { | 795 | { |
796 | <<<<<<< HEAD | ||
725 | // Force a final state save | 797 | // Force a final state save |
726 | // | 798 | // |
727 | try | 799 | try |
728 | { | 800 | { |
729 | if (instance.StatePersistedHere) | 801 | if (instance.StatePersistedHere) |
730 | instance.SaveState(); | 802 | instance.SaveState(); |
803 | ======= | ||
804 | string assembly = m_Assemblies[instance.AssetID]; | ||
805 | |||
806 | try | ||
807 | { | ||
808 | instance.SaveState(assembly); | ||
809 | >>>>>>> avn/ubitvar | ||
731 | } | 810 | } |
732 | catch (Exception e) | 811 | catch (Exception e) |
733 | { | 812 | { |
@@ -737,36 +816,50 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
737 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) | 816 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) |
738 | , e); | 817 | , e); |
739 | } | 818 | } |
819 | } | ||
740 | 820 | ||
821 | <<<<<<< HEAD | ||
741 | // Clear the event queue and abort the instance thread | 822 | // Clear the event queue and abort the instance thread |
742 | // | 823 | // |
743 | instance.Stop(0, true); | 824 | instance.Stop(0, true); |
825 | ======= | ||
826 | // Clear the event queue and abort the instance thread | ||
827 | // | ||
828 | instance.ClearQueue(); | ||
829 | instance.Stop(0); | ||
830 | >>>>>>> avn/ubitvar | ||
744 | 831 | ||
745 | // Release events, timer, etc | 832 | // Release events, timer, etc |
746 | // | 833 | // |
747 | instance.DestroyScriptInstance(); | 834 | instance.DestroyScriptInstance(); |
748 | 835 | ||
749 | // Unload scripts and app domains. | 836 | // Unload scripts and app domains |
750 | // Must be done explicitly because they have infinite | 837 | // Must be done explicitly because they have infinite |
751 | // lifetime. | 838 | // lifetime |
752 | // However, don't bother to do this if the simulator is shutting | 839 | // |
753 | // down since it takes a long time with many scripts. | 840 | // if (!m_SimulatorShuttingDown) |
754 | if (!m_SimulatorShuttingDown) | 841 | { |
842 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | ||
843 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
755 | { | 844 | { |
756 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 845 | m_DomainScripts.Remove(instance.AppDomain); |
757 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 846 | UnloadAppDomain(instance.AppDomain); |
758 | { | ||
759 | m_DomainScripts.Remove(instance.AppDomain); | ||
760 | UnloadAppDomain(instance.AppDomain); | ||
761 | } | ||
762 | } | 847 | } |
763 | } | 848 | } |
764 | 849 | ||
765 | m_Scripts.Clear(); | 850 | // m_Scripts.Clear(); |
766 | m_PrimObjects.Clear(); | 851 | // m_PrimObjects.Clear(); |
767 | m_Assemblies.Clear(); | 852 | // m_Assemblies.Clear(); |
768 | m_DomainScripts.Clear(); | 853 | // m_DomainScripts.Clear(); |
769 | } | 854 | } |
855 | lockScriptsForRead(false); | ||
856 | lockScriptsForWrite(true); | ||
857 | m_Scripts.Clear(); | ||
858 | lockScriptsForWrite(false); | ||
859 | m_PrimObjects.Clear(); | ||
860 | m_Assemblies.Clear(); | ||
861 | m_DomainScripts.Clear(); | ||
862 | |||
770 | lock (m_ScriptEngines) | 863 | lock (m_ScriptEngines) |
771 | { | 864 | { |
772 | m_ScriptEngines.Remove(this); | 865 | m_ScriptEngines.Remove(this); |
@@ -835,6 +928,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
835 | 928 | ||
836 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 929 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
837 | 930 | ||
931 | <<<<<<< HEAD | ||
838 | lock (m_Scripts) | 932 | lock (m_Scripts) |
839 | { | 933 | { |
840 | foreach (IScriptInstance instance in m_Scripts.Values) | 934 | foreach (IScriptInstance instance in m_Scripts.Values) |
@@ -852,6 +946,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
852 | 946 | ||
853 | foreach (IScriptInstance i in instances) | 947 | foreach (IScriptInstance i in instances) |
854 | { | 948 | { |
949 | ======= | ||
950 | lockScriptsForRead(true); | ||
951 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
952 | instances.Add(instance); | ||
953 | lockScriptsForRead(false); | ||
954 | |||
955 | foreach (IScriptInstance i in instances) | ||
956 | { | ||
957 | string assembly = String.Empty; | ||
958 | |||
959 | |||
960 | if (!m_Assemblies.ContainsKey(i.AssetID)) | ||
961 | continue; | ||
962 | assembly = m_Assemblies[i.AssetID]; | ||
963 | |||
964 | |||
965 | >>>>>>> avn/ubitvar | ||
855 | try | 966 | try |
856 | { | 967 | { |
857 | i.SaveState(); | 968 | i.SaveState(); |
@@ -1282,58 +1393,79 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1282 | } | 1393 | } |
1283 | 1394 | ||
1284 | ScriptInstance instance = null; | 1395 | ScriptInstance instance = null; |
1285 | lock (m_Scripts) | 1396 | // Create the object record |
1397 | UUID appDomain = assetID; | ||
1398 | |||
1399 | |||
1400 | |||
1401 | lockScriptsForRead(true); | ||
1402 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
1403 | (m_Scripts[itemID].AssetID != assetID)) | ||
1286 | { | 1404 | { |
1287 | // Create the object record | 1405 | lockScriptsForRead(false); |
1288 | if ((!m_Scripts.ContainsKey(itemID)) || | 1406 | instance = new ScriptInstance(this, part, |
1289 | (m_Scripts[itemID].AssetID != assetID)) | 1407 | item, |
1290 | { | 1408 | startParam, postOnRez, |
1291 | UUID appDomain = assetID; | 1409 | m_MaxScriptQueue); |
1292 | 1410 | ||
1293 | if (part.ParentGroup.IsAttachment) | 1411 | if (part.ParentGroup.IsAttachment) |
1294 | appDomain = part.ParentGroup.RootPart.UUID; | 1412 | appDomain = part.ParentGroup.RootPart.UUID; |
1295 | 1413 | ||
1296 | if (!m_AppDomains.ContainsKey(appDomain)) | 1414 | if (!m_AppDomains.ContainsKey(appDomain)) |
1415 | { | ||
1416 | try | ||
1297 | { | 1417 | { |
1298 | try | 1418 | AppDomainSetup appSetup = new AppDomainSetup(); |
1299 | { | 1419 | appSetup.PrivateBinPath = Path.Combine( |
1300 | AppDomainSetup appSetup = new AppDomainSetup(); | 1420 | m_ScriptEnginesPath, |
1301 | appSetup.PrivateBinPath = Path.Combine( | 1421 | m_Scene.RegionInfo.RegionID.ToString()); |
1302 | m_ScriptEnginesPath, | ||
1303 | m_Scene.RegionInfo.RegionID.ToString()); | ||
1304 | 1422 | ||
1305 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 1423 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
1306 | Evidence evidence = new Evidence(baseEvidence); | 1424 | Evidence evidence = new Evidence(baseEvidence); |
1307 | 1425 | ||
1308 | AppDomain sandbox; | 1426 | AppDomain sandbox; |
1309 | if (m_AppDomainLoading) | 1427 | if (m_AppDomainLoading) |
1428 | { | ||
1429 | sandbox = AppDomain.CreateDomain( | ||
1430 | m_Scene.RegionInfo.RegionID.ToString(), | ||
1431 | evidence, appSetup); | ||
1432 | if (m_AppDomains.ContainsKey(appDomain)) | ||
1310 | { | 1433 | { |
1311 | sandbox = AppDomain.CreateDomain( | 1434 | m_AppDomains[appDomain].AssemblyResolve += |
1312 | m_Scene.RegionInfo.RegionID.ToString(), | ||
1313 | evidence, appSetup); | ||
1314 | sandbox.AssemblyResolve += | ||
1315 | new ResolveEventHandler( | 1435 | new ResolveEventHandler( |
1316 | AssemblyResolver.OnAssemblyResolve); | 1436 | AssemblyResolver.OnAssemblyResolve); |
1437 | if (m_DomainScripts.ContainsKey(appDomain)) | ||
1438 | { | ||
1439 | m_DomainScripts[appDomain].Add(itemID); | ||
1440 | } | ||
1441 | else | ||
1442 | { | ||
1443 | m_DomainScripts.Add(appDomain, new List<UUID>()); | ||
1444 | m_DomainScripts[appDomain].Add(itemID); | ||
1445 | } | ||
1317 | } | 1446 | } |
1318 | else | 1447 | else |
1319 | { | 1448 | { |
1320 | sandbox = AppDomain.CurrentDomain; | 1449 | m_AppDomains.Add(appDomain, sandbox); |
1450 | m_AppDomains[appDomain].AssemblyResolve += | ||
1451 | new ResolveEventHandler( | ||
1452 | AssemblyResolver.OnAssemblyResolve); | ||
1453 | if (m_DomainScripts.ContainsKey(appDomain)) | ||
1454 | { | ||
1455 | m_DomainScripts[appDomain].Add(itemID); | ||
1456 | } | ||
1457 | else | ||
1458 | { | ||
1459 | m_DomainScripts.Add(appDomain, new List<UUID>()); | ||
1460 | m_DomainScripts[appDomain].Add(itemID); | ||
1461 | } | ||
1462 | |||
1321 | } | 1463 | } |
1322 | |||
1323 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | ||
1324 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | ||
1325 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | ||
1326 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | ||
1327 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | ||
1328 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | ||
1329 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | ||
1330 | |||
1331 | m_AppDomains[appDomain] = sandbox; | ||
1332 | 1464 | ||
1333 | m_DomainScripts[appDomain] = new List<UUID>(); | ||
1334 | } | 1465 | } |
1335 | catch (Exception e) | 1466 | else |
1336 | { | 1467 | { |
1468 | <<<<<<< HEAD | ||
1337 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | 1469 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
1338 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | 1470 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
1339 | m_ScriptFailCount++; | 1471 | m_ScriptFailCount++; |
@@ -1342,10 +1474,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1342 | m_AddingAssemblies[assemblyPath]--; | 1474 | m_AddingAssemblies[assemblyPath]--; |
1343 | } | 1475 | } |
1344 | return false; | 1476 | return false; |
1477 | ======= | ||
1478 | sandbox = AppDomain.CurrentDomain; | ||
1479 | >>>>>>> avn/ubitvar | ||
1345 | } | 1480 | } |
1346 | } | ||
1347 | m_DomainScripts[appDomain].Add(itemID); | ||
1348 | 1481 | ||
1482 | <<<<<<< HEAD | ||
1349 | IScript scriptObj = null; | 1483 | IScript scriptObj = null; |
1350 | EventWaitHandle coopSleepHandle; | 1484 | EventWaitHandle coopSleepHandle; |
1351 | bool coopTerminationForThisScript; | 1485 | bool coopTerminationForThisScript; |
@@ -1477,26 +1611,52 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1477 | scriptObj, coopSleepHandle, assemblyPath, | 1611 | scriptObj, coopSleepHandle, assemblyPath, |
1478 | Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) | 1612 | Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) |
1479 | return false; | 1613 | return false; |
1614 | ======= | ||
1615 | // if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) | ||
1616 | // return false; | ||
1617 | >>>>>>> avn/ubitvar | ||
1480 | 1618 | ||
1481 | // if (DebugLevel >= 1) | 1619 | m_AppDomains[appDomain] = sandbox; |
1482 | // m_log.DebugFormat( | ||
1483 | // "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | ||
1484 | // part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | ||
1485 | // part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
1486 | 1620 | ||
1487 | if (presence != null) | 1621 | m_DomainScripts[appDomain] = new List<UUID>(); |
1622 | } | ||
1623 | catch (Exception e) | ||
1488 | { | 1624 | { |
1489 | ShowScriptSaveResponse(item.OwnerID, | 1625 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
1490 | assetID, "Compile successful", true); | 1626 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
1627 | m_ScriptFailCount++; | ||
1628 | lock (m_AddingAssemblies) | ||
1629 | { | ||
1630 | m_AddingAssemblies[assembly]--; | ||
1631 | } | ||
1632 | return false; | ||
1491 | } | 1633 | } |
1634 | } | ||
1492 | 1635 | ||
1493 | instance.AppDomain = appDomain; | ||
1494 | instance.LineMap = linemap; | ||
1495 | 1636 | ||
1496 | m_Scripts[itemID] = instance; | 1637 | if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) |
1638 | return false; | ||
1639 | // m_log.DebugFormat( | ||
1640 | // "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", | ||
1641 | // part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | ||
1642 | // part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
1643 | |||
1644 | if (presence != null) | ||
1645 | { | ||
1646 | ShowScriptSaveResponse(item.OwnerID, | ||
1647 | assetID, "Compile successful", true); | ||
1497 | } | 1648 | } |
1498 | } | ||
1499 | 1649 | ||
1650 | instance.AppDomain = appDomain; | ||
1651 | instance.LineMap = linemap; | ||
1652 | lockScriptsForWrite(true); | ||
1653 | m_Scripts[itemID] = instance; | ||
1654 | lockScriptsForWrite(false); | ||
1655 | } | ||
1656 | else | ||
1657 | { | ||
1658 | lockScriptsForRead(false); | ||
1659 | } | ||
1500 | lock (m_PrimObjects) | 1660 | lock (m_PrimObjects) |
1501 | { | 1661 | { |
1502 | if (!m_PrimObjects.ContainsKey(localID)) | 1662 | if (!m_PrimObjects.ContainsKey(localID)) |
@@ -1514,7 +1674,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1514 | m_AddingAssemblies[assemblyPath]--; | 1674 | m_AddingAssemblies[assemblyPath]--; |
1515 | } | 1675 | } |
1516 | 1676 | ||
1517 | if (instance != null) | 1677 | if (instance!=null) |
1518 | instance.Init(); | 1678 | instance.Init(); |
1519 | 1679 | ||
1520 | bool runIt; | 1680 | bool runIt; |
@@ -1537,19 +1697,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1537 | m_CompileDict.Remove(itemID); | 1697 | m_CompileDict.Remove(itemID); |
1538 | } | 1698 | } |
1539 | 1699 | ||
1540 | IScriptInstance instance = null; | 1700 | lockScriptsForRead(true); |
1541 | 1701 | // Do we even have it? | |
1542 | lock (m_Scripts) | 1702 | if (!m_Scripts.ContainsKey(itemID)) |
1543 | { | 1703 | { |
1544 | // Do we even have it? | 1704 | lockScriptsForRead(false); |
1545 | if (!m_Scripts.ContainsKey(itemID)) | 1705 | return; |
1546 | return; | 1706 | } |
1547 | |||
1548 | instance = m_Scripts[itemID]; | ||
1549 | m_Scripts.Remove(itemID); | ||
1550 | } | ||
1551 | 1707 | ||
1708 | <<<<<<< HEAD | ||
1552 | instance.Stop(m_WaitForEventCompletionOnScriptStop, true); | 1709 | instance.Stop(m_WaitForEventCompletionOnScriptStop, true); |
1710 | ======= | ||
1711 | IScriptInstance instance=m_Scripts[itemID]; | ||
1712 | lockScriptsForRead(false); | ||
1713 | lockScriptsForWrite(true); | ||
1714 | m_Scripts.Remove(itemID); | ||
1715 | lockScriptsForWrite(false); | ||
1716 | instance.ClearQueue(); | ||
1717 | |||
1718 | instance.Stop(m_WaitForEventCompletionOnScriptStop); | ||
1719 | |||
1720 | // bool objectRemoved = false; | ||
1721 | >>>>>>> avn/ubitvar | ||
1553 | 1722 | ||
1554 | lock (m_PrimObjects) | 1723 | lock (m_PrimObjects) |
1555 | { | 1724 | { |
@@ -1571,17 +1740,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1571 | 1740 | ||
1572 | instance.DestroyScriptInstance(); | 1741 | instance.DestroyScriptInstance(); |
1573 | 1742 | ||
1574 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 1743 | if (m_DomainScripts.ContainsKey(instance.AppDomain)) |
1575 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
1576 | { | 1744 | { |
1577 | m_DomainScripts.Remove(instance.AppDomain); | 1745 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
1578 | UnloadAppDomain(instance.AppDomain); | 1746 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
1747 | { | ||
1748 | m_DomainScripts.Remove(instance.AppDomain); | ||
1749 | UnloadAppDomain(instance.AppDomain); | ||
1750 | } | ||
1579 | } | 1751 | } |
1580 | 1752 | ||
1581 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 1753 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
1582 | if (handlerObjectRemoved != null) | 1754 | if (handlerObjectRemoved != null) |
1583 | handlerObjectRemoved(instance.ObjectID); | 1755 | { |
1756 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
1757 | if (part != null) | ||
1758 | handlerObjectRemoved(part.UUID); | ||
1759 | } | ||
1584 | 1760 | ||
1761 | CleanAssemblies(); | ||
1762 | |||
1585 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 1763 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
1586 | if (handlerScriptRemoved != null) | 1764 | if (handlerScriptRemoved != null) |
1587 | handlerScriptRemoved(itemID); | 1765 | handlerScriptRemoved(itemID); |
@@ -1842,12 +2020,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1842 | private IScriptInstance GetInstance(UUID itemID) | 2020 | private IScriptInstance GetInstance(UUID itemID) |
1843 | { | 2021 | { |
1844 | IScriptInstance instance; | 2022 | IScriptInstance instance; |
1845 | lock (m_Scripts) | 2023 | lockScriptsForRead(true); |
2024 | if (!m_Scripts.ContainsKey(itemID)) | ||
1846 | { | 2025 | { |
1847 | if (!m_Scripts.ContainsKey(itemID)) | 2026 | lockScriptsForRead(false); |
1848 | return null; | 2027 | return null; |
1849 | instance = m_Scripts[itemID]; | ||
1850 | } | 2028 | } |
2029 | instance = m_Scripts[itemID]; | ||
2030 | lockScriptsForRead(false); | ||
1851 | return instance; | 2031 | return instance; |
1852 | } | 2032 | } |
1853 | 2033 | ||
@@ -1869,6 +2049,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1869 | return instance != null && instance.Running; | 2049 | return instance != null && instance.Running; |
1870 | } | 2050 | } |
1871 | 2051 | ||
2052 | [DebuggerNonUserCode] | ||
1872 | public void ApiResetScript(UUID itemID) | 2053 | public void ApiResetScript(UUID itemID) |
1873 | { | 2054 | { |
1874 | IScriptInstance instance = GetInstance(itemID); | 2055 | IScriptInstance instance = GetInstance(itemID); |
@@ -1953,6 +2134,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1953 | return instance != null ? instance.GetDetectID(idx) : UUID.Zero; | 2134 | return instance != null ? instance.GetDetectID(idx) : UUID.Zero; |
1954 | } | 2135 | } |
1955 | 2136 | ||
2137 | [DebuggerNonUserCode] | ||
1956 | public void SetState(UUID itemID, string newState) | 2138 | public void SetState(UUID itemID, string newState) |
1957 | { | 2139 | { |
1958 | IScriptInstance instance = GetInstance(itemID); | 2140 | IScriptInstance instance = GetInstance(itemID); |
@@ -1973,11 +2155,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1973 | 2155 | ||
1974 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 2156 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
1975 | 2157 | ||
1976 | lock (m_Scripts) | 2158 | lockScriptsForRead(true); |
1977 | { | 2159 | foreach (IScriptInstance instance in m_Scripts.Values) |
1978 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
1979 | instances.Add(instance); | 2160 | instances.Add(instance); |
1980 | } | 2161 | lockScriptsForRead(false); |
1981 | 2162 | ||
1982 | foreach (IScriptInstance i in instances) | 2163 | foreach (IScriptInstance i in instances) |
1983 | { | 2164 | { |