diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
17 files changed, 559 insertions, 467 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs index 47ed6ba..684138f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs | |||
@@ -29,42 +29,43 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | ||
32 | using OpenSim.Region.ScriptEngine.Interfaces; | 33 | using OpenSim.Region.ScriptEngine.Interfaces; |
33 | 34 | ||
34 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 35 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
35 | { | 36 | { |
36 | public class ApiManager | 37 | public class ApiManager |
37 | { | 38 | { |
39 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
38 | private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); | 41 | private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); |
39 | 42 | ||
40 | public string[] GetApis() | 43 | public string[] GetApis() |
41 | { | 44 | { |
42 | if (m_Apis.Count > 0) | 45 | if (m_Apis.Count <= 0) |
43 | { | 46 | { |
44 | List<string> l = new List<string>(m_Apis.Keys); | 47 | Assembly a = Assembly.GetExecutingAssembly(); |
45 | return l.ToArray(); | ||
46 | } | ||
47 | 48 | ||
48 | Assembly a = Assembly.GetExecutingAssembly(); | 49 | Type[] types = a.GetExportedTypes(); |
49 | 50 | ||
50 | Type[] types = a.GetExportedTypes(); | 51 | foreach (Type t in types) |
51 | |||
52 | foreach (Type t in types) | ||
53 | { | ||
54 | string name = t.ToString(); | ||
55 | int idx = name.LastIndexOf('.'); | ||
56 | if (idx != -1) | ||
57 | name = name.Substring(idx+1); | ||
58 | |||
59 | if (name.EndsWith("_Api")) | ||
60 | { | 52 | { |
61 | name = name.Substring(0, name.Length - 4); | 53 | string name = t.ToString(); |
62 | m_Apis[name] = t; | 54 | int idx = name.LastIndexOf('.'); |
55 | if (idx != -1) | ||
56 | name = name.Substring(idx+1); | ||
57 | |||
58 | if (name.EndsWith("_Api")) | ||
59 | { | ||
60 | name = name.Substring(0, name.Length - 4); | ||
61 | m_Apis[name] = t; | ||
62 | } | ||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | List<string> ret = new List<string>(m_Apis.Keys); | 66 | // m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count); |
67 | return ret.ToArray(); | 67 | |
68 | return new List<string>(m_Apis.Keys).ToArray(); | ||
68 | } | 69 | } |
69 | 70 | ||
70 | public IScriptApi CreateApi(string api) | 71 | public IScriptApi CreateApi(string api) |
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
76 | return ret; | 77 | return ret; |
77 | } | 78 | } |
78 | } | 79 | } |
79 | } | 80 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6ee1a5d..3fe5780 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -89,7 +89,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
89 | protected IScriptEngine m_ScriptEngine; | 89 | protected IScriptEngine m_ScriptEngine; |
90 | protected SceneObjectPart m_host; | 90 | protected SceneObjectPart m_host; |
91 | protected uint m_localID; | 91 | protected uint m_localID; |
92 | |||
93 | /// <summary> | ||
94 | /// The UUID of the item that hosts this script | ||
95 | /// </summary> | ||
92 | protected UUID m_itemID; | 96 | protected UUID m_itemID; |
97 | |||
93 | protected bool throwErrorOnNotImplemented = true; | 98 | protected bool throwErrorOnNotImplemented = true; |
94 | protected AsyncCommandManager AsyncCommands = null; | 99 | protected AsyncCommandManager AsyncCommands = null; |
95 | protected float m_ScriptDelayFactor = 1.0f; | 100 | protected float m_ScriptDelayFactor = 1.0f; |
@@ -336,28 +341,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
336 | } | 341 | } |
337 | } | 342 | } |
338 | 343 | ||
339 | protected UUID InventorySelf() | 344 | /// <summary> |
345 | /// Get the inventory item that hosts ourselves. | ||
346 | /// </summary> | ||
347 | /// <remarks> | ||
348 | /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need | ||
349 | /// to keep looking ourselves up. | ||
350 | /// </remarks> | ||
351 | /// <returns></returns> | ||
352 | protected TaskInventoryItem GetSelfInventoryItem() | ||
340 | { | 353 | { |
341 | UUID invItemID = new UUID(); | 354 | TaskInventoryItem invItem = null; |
355 | |||
342 | bool unlock = false; | 356 | bool unlock = false; |
343 | if (!m_host.TaskInventory.IsReadLockedByMe()) | 357 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
344 | { | 358 | { |
345 | m_host.TaskInventory.LockItemsForRead(true); | 359 | m_host.TaskInventory.LockItemsForRead(true); |
346 | unlock = true; | 360 | unlock = true; |
347 | } | 361 | } |
348 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 362 | |
349 | { | 363 | invItem = m_host.TaskInventory[m_itemID]; |
350 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 364 | |
351 | { | ||
352 | invItemID = inv.Key; | ||
353 | break; | ||
354 | } | ||
355 | } | ||
356 | if (unlock) | 365 | if (unlock) |
357 | { | 366 | { |
358 | m_host.TaskInventory.LockItemsForRead(false); | 367 | m_host.TaskInventory.LockItemsForRead(false); |
359 | } | 368 | } |
360 | return invItemID; | 369 | |
370 | return invItem; | ||
361 | } | 371 | } |
362 | 372 | ||
363 | protected UUID InventoryKey(string name, int type) | 373 | protected UUID InventoryKey(string name, int type) |
@@ -941,20 +951,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
941 | 951 | ||
942 | public void llRegionSayTo(string target, int channel, string msg) | 952 | public void llRegionSayTo(string target, int channel, string msg) |
943 | { | 953 | { |
944 | string error = String.Empty; | ||
945 | |||
946 | if (msg.Length > 1023) | 954 | if (msg.Length > 1023) |
947 | msg = msg.Substring(0, 1023); | 955 | msg = msg.Substring(0, 1023); |
948 | 956 | ||
949 | m_host.AddScriptLPS(1); | 957 | m_host.AddScriptLPS(1); |
950 | 958 | ||
959 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
960 | { | ||
961 | return; | ||
962 | } | ||
963 | |||
951 | UUID TargetID; | 964 | UUID TargetID; |
952 | UUID.TryParse(target, out TargetID); | 965 | UUID.TryParse(target, out TargetID); |
953 | 966 | ||
954 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 967 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
955 | if (wComm != null) | 968 | if (wComm != null) |
956 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) | 969 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); |
957 | LSLError(error); | ||
958 | } | 970 | } |
959 | 971 | ||
960 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 972 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -2948,15 +2960,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2948 | 2960 | ||
2949 | public LSL_Integer llGiveMoney(string destination, int amount) | 2961 | public LSL_Integer llGiveMoney(string destination, int amount) |
2950 | { | 2962 | { |
2951 | UUID invItemID=InventorySelf(); | ||
2952 | if (invItemID == UUID.Zero) | ||
2953 | return 0; | ||
2954 | |||
2955 | m_host.AddScriptLPS(1); | 2963 | m_host.AddScriptLPS(1); |
2956 | 2964 | ||
2957 | m_host.TaskInventory.LockItemsForRead(true); | 2965 | TaskInventoryItem item = GetSelfInventoryItem(); |
2958 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
2959 | m_host.TaskInventory.LockItemsForRead(false); | ||
2960 | 2966 | ||
2961 | if (item.PermsGranter == UUID.Zero) | 2967 | if (item.PermsGranter == UUID.Zero) |
2962 | return 0; | 2968 | return 0; |
@@ -3210,19 +3216,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3210 | 3216 | ||
3211 | public void llTakeControls(int controls, int accept, int pass_on) | 3217 | public void llTakeControls(int controls, int accept, int pass_on) |
3212 | { | 3218 | { |
3213 | TaskInventoryItem item; | 3219 | TaskInventoryItem item = GetSelfInventoryItem(); |
3214 | |||
3215 | m_host.TaskInventory.LockItemsForRead(true); | ||
3216 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3217 | { | ||
3218 | m_host.TaskInventory.LockItemsForRead(false); | ||
3219 | return; | ||
3220 | } | ||
3221 | else | ||
3222 | { | ||
3223 | item = m_host.TaskInventory[InventorySelf()]; | ||
3224 | } | ||
3225 | m_host.TaskInventory.LockItemsForRead(false); | ||
3226 | 3220 | ||
3227 | if (item.PermsGranter != UUID.Zero) | 3221 | if (item.PermsGranter != UUID.Zero) |
3228 | { | 3222 | { |
@@ -3242,26 +3236,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3242 | 3236 | ||
3243 | public void llReleaseControls() | 3237 | public void llReleaseControls() |
3244 | { | 3238 | { |
3245 | TaskInventoryItem item; | ||
3246 | |||
3247 | m_host.TaskInventory.LockItemsForRead(true); | ||
3248 | lock (m_host.TaskInventory) | ||
3249 | { | ||
3250 | |||
3251 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3252 | { | ||
3253 | m_host.TaskInventory.LockItemsForRead(false); | ||
3254 | return; | ||
3255 | } | ||
3256 | else | ||
3257 | { | ||
3258 | item = m_host.TaskInventory[InventorySelf()]; | ||
3259 | } | ||
3260 | } | ||
3261 | m_host.TaskInventory.LockItemsForRead(false); | ||
3262 | |||
3263 | m_host.AddScriptLPS(1); | 3239 | m_host.AddScriptLPS(1); |
3264 | 3240 | ||
3241 | TaskInventoryItem item = GetSelfInventoryItem(); | ||
3242 | |||
3265 | if (item.PermsGranter != UUID.Zero) | 3243 | if (item.PermsGranter != UUID.Zero) |
3266 | { | 3244 | { |
3267 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | 3245 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); |
@@ -3286,86 +3264,77 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3286 | m_UrlModule.ReleaseURL(url); | 3264 | m_UrlModule.ReleaseURL(url); |
3287 | } | 3265 | } |
3288 | 3266 | ||
3289 | public void llAttachToAvatar(int attachment) | 3267 | /// <summary> |
3268 | /// Attach the object containing this script to the avatar that owns it. | ||
3269 | /// </summary> | ||
3270 | /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param> | ||
3271 | /// <returns>true if the attach suceeded, false if it did not</returns> | ||
3272 | public bool AttachToAvatar(int attachmentPoint) | ||
3290 | { | 3273 | { |
3291 | m_host.AddScriptLPS(1); | 3274 | SceneObjectGroup grp = m_host.ParentGroup; |
3292 | 3275 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | |
3293 | TaskInventoryItem item; | ||
3294 | 3276 | ||
3295 | m_host.TaskInventory.LockItemsForRead(true); | 3277 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3296 | 3278 | ||
3297 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3279 | if (attachmentsModule != null) |
3298 | { | 3280 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); |
3299 | m_host.TaskInventory.LockItemsForRead(false); | ||
3300 | return; | ||
3301 | } | ||
3302 | else | 3281 | else |
3303 | { | 3282 | return false; |
3304 | item = m_host.TaskInventory[InventorySelf()]; | 3283 | } |
3305 | } | ||
3306 | |||
3307 | m_host.TaskInventory.LockItemsForRead(false); | ||
3308 | 3284 | ||
3309 | if (item.PermsGranter != m_host.OwnerID) | 3285 | /// <summary> |
3310 | return; | 3286 | /// Detach the object containing this script from the avatar it is attached to. |
3287 | /// </summary> | ||
3288 | /// <remarks> | ||
3289 | /// Nothing happens if the object is not attached. | ||
3290 | /// </remarks> | ||
3291 | public void DetachFromAvatar() | ||
3292 | { | ||
3293 | Util.FireAndForget(DetachWrapper, m_host); | ||
3294 | } | ||
3311 | 3295 | ||
3312 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3296 | private void DetachWrapper(object o) |
3313 | { | 3297 | { |
3314 | SceneObjectGroup grp = m_host.ParentGroup; | 3298 | SceneObjectPart host = (SceneObjectPart)o; |
3315 | 3299 | ||
3316 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3300 | SceneObjectGroup grp = host.ParentGroup; |
3301 | UUID itemID = grp.FromItemID; | ||
3302 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3317 | 3303 | ||
3318 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3304 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3319 | if (attachmentsModule != null) | 3305 | if (attachmentsModule != null) |
3320 | attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); | 3306 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); |
3321 | } | ||
3322 | } | 3307 | } |
3323 | 3308 | ||
3324 | public void llDetachFromAvatar() | 3309 | public void llAttachToAvatar(int attachmentPoint) |
3325 | { | 3310 | { |
3326 | m_host.AddScriptLPS(1); | 3311 | m_host.AddScriptLPS(1); |
3327 | 3312 | ||
3328 | if (m_host.ParentGroup.AttachmentPoint == 0) | 3313 | TaskInventoryItem item = GetSelfInventoryItem(); |
3329 | return; | ||
3330 | 3314 | ||
3331 | TaskInventoryItem item; | ||
3332 | |||
3333 | m_host.TaskInventory.LockItemsForRead(true); | ||
3334 | |||
3335 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3336 | { | ||
3337 | m_host.TaskInventory.LockItemsForRead(false); | ||
3338 | return; | ||
3339 | } | ||
3340 | else | ||
3341 | { | ||
3342 | item = m_host.TaskInventory[InventorySelf()]; | ||
3343 | } | ||
3344 | m_host.TaskInventory.LockItemsForRead(false); | 3315 | m_host.TaskInventory.LockItemsForRead(false); |
3345 | 3316 | ||
3346 | |||
3347 | if (item.PermsGranter != m_host.OwnerID) | 3317 | if (item.PermsGranter != m_host.OwnerID) |
3348 | return; | 3318 | return; |
3349 | 3319 | ||
3350 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3320 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) |
3351 | { | 3321 | AttachToAvatar(attachmentPoint); |
3352 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3353 | if (attachmentsModule != null) | ||
3354 | Util.FireAndForget(DetachWrapper, m_host); | ||
3355 | } | ||
3356 | } | 3322 | } |
3357 | 3323 | ||
3358 | private void DetachWrapper(object o) | 3324 | public void llDetachFromAvatar() |
3359 | { | 3325 | { |
3360 | SceneObjectPart host = (SceneObjectPart)o; | 3326 | m_host.AddScriptLPS(1); |
3361 | 3327 | ||
3362 | SceneObjectGroup grp = host.ParentGroup; | 3328 | if (m_host.ParentGroup.AttachmentPoint == 0) |
3363 | UUID itemID = grp.FromItemID; | 3329 | return; |
3364 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3365 | 3330 | ||
3366 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3331 | TaskInventoryItem item = GetSelfInventoryItem(); |
3367 | if (attachmentsModule != null) | 3332 | |
3368 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); | 3333 | if (item.PermsGranter != m_host.OwnerID) |
3334 | return; | ||
3335 | |||
3336 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | ||
3337 | DetachFromAvatar(); | ||
3369 | } | 3338 | } |
3370 | 3339 | ||
3371 | public void llTakeCamera(string avatar) | 3340 | public void llTakeCamera(string avatar) |
@@ -3622,23 +3591,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3622 | { | 3591 | { |
3623 | m_host.AddScriptLPS(1); | 3592 | m_host.AddScriptLPS(1); |
3624 | 3593 | ||
3625 | UUID invItemID = InventorySelf(); | 3594 | TaskInventoryItem item = GetSelfInventoryItem(); |
3626 | if (invItemID == UUID.Zero) | ||
3627 | return; | ||
3628 | |||
3629 | TaskInventoryItem item; | ||
3630 | 3595 | ||
3631 | m_host.TaskInventory.LockItemsForRead(true); | ||
3632 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3633 | { | ||
3634 | m_host.TaskInventory.LockItemsForRead(false); | ||
3635 | return; | ||
3636 | } | ||
3637 | else | ||
3638 | { | ||
3639 | item = m_host.TaskInventory[InventorySelf()]; | ||
3640 | } | ||
3641 | m_host.TaskInventory.LockItemsForRead(false); | ||
3642 | if (item.PermsGranter == UUID.Zero) | 3596 | if (item.PermsGranter == UUID.Zero) |
3643 | return; | 3597 | return; |
3644 | 3598 | ||
@@ -3662,24 +3616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3662 | { | 3616 | { |
3663 | m_host.AddScriptLPS(1); | 3617 | m_host.AddScriptLPS(1); |
3664 | 3618 | ||
3665 | UUID invItemID=InventorySelf(); | 3619 | TaskInventoryItem item = GetSelfInventoryItem(); |
3666 | if (invItemID == UUID.Zero) | ||
3667 | return; | ||
3668 | |||
3669 | TaskInventoryItem item; | ||
3670 | |||
3671 | m_host.TaskInventory.LockItemsForRead(true); | ||
3672 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3673 | { | ||
3674 | m_host.TaskInventory.LockItemsForRead(false); | ||
3675 | return; | ||
3676 | } | ||
3677 | else | ||
3678 | { | ||
3679 | item = m_host.TaskInventory[InventorySelf()]; | ||
3680 | } | ||
3681 | m_host.TaskInventory.LockItemsForRead(false); | ||
3682 | |||
3683 | 3620 | ||
3684 | if (item.PermsGranter == UUID.Zero) | 3621 | if (item.PermsGranter == UUID.Zero) |
3685 | return; | 3622 | return; |
@@ -3734,30 +3671,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3734 | 3671 | ||
3735 | public void llRequestPermissions(string agent, int perm) | 3672 | public void llRequestPermissions(string agent, int perm) |
3736 | { | 3673 | { |
3737 | UUID agentID = new UUID(); | 3674 | UUID agentID; |
3738 | 3675 | ||
3739 | if (!UUID.TryParse(agent, out agentID)) | 3676 | if (!UUID.TryParse(agent, out agentID)) |
3740 | return; | 3677 | return; |
3741 | 3678 | ||
3742 | UUID invItemID = InventorySelf(); | 3679 | TaskInventoryItem item = GetSelfInventoryItem(); |
3743 | |||
3744 | if (invItemID == UUID.Zero) | ||
3745 | return; // Not in a prim? How?? | ||
3746 | |||
3747 | TaskInventoryItem item; | ||
3748 | |||
3749 | |||
3750 | m_host.TaskInventory.LockItemsForRead(true); | ||
3751 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3752 | { | ||
3753 | m_host.TaskInventory.LockItemsForRead(false); | ||
3754 | return; | ||
3755 | } | ||
3756 | else | ||
3757 | { | ||
3758 | item = m_host.TaskInventory[invItemID]; | ||
3759 | } | ||
3760 | m_host.TaskInventory.LockItemsForRead(false); | ||
3761 | 3680 | ||
3762 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3681 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3763 | { | 3682 | { |
@@ -3791,8 +3710,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3791 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3710 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3792 | { | 3711 | { |
3793 | m_host.TaskInventory.LockItemsForWrite(true); | 3712 | m_host.TaskInventory.LockItemsForWrite(true); |
3794 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3713 | m_host.TaskInventory[m_itemID].PermsGranter = agentID; |
3795 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3714 | m_host.TaskInventory[m_itemID].PermsMask = perm; |
3796 | m_host.TaskInventory.LockItemsForWrite(false); | 3715 | m_host.TaskInventory.LockItemsForWrite(false); |
3797 | 3716 | ||
3798 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3717 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
@@ -3830,8 +3749,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3830 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3749 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3831 | { | 3750 | { |
3832 | m_host.TaskInventory.LockItemsForWrite(true); | 3751 | m_host.TaskInventory.LockItemsForWrite(true); |
3833 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3752 | m_host.TaskInventory[m_itemID].PermsGranter = agentID; |
3834 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3753 | m_host.TaskInventory[m_itemID].PermsMask = perm; |
3835 | m_host.TaskInventory.LockItemsForWrite(false); | 3754 | m_host.TaskInventory.LockItemsForWrite(false); |
3836 | 3755 | ||
3837 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3756 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
@@ -3855,8 +3774,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3855 | if (!m_waitingForScriptAnswer) | 3774 | if (!m_waitingForScriptAnswer) |
3856 | { | 3775 | { |
3857 | m_host.TaskInventory.LockItemsForWrite(true); | 3776 | m_host.TaskInventory.LockItemsForWrite(true); |
3858 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3777 | m_host.TaskInventory[m_itemID].PermsGranter = agentID; |
3859 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3778 | m_host.TaskInventory[m_itemID].PermsMask = 0; |
3860 | m_host.TaskInventory.LockItemsForWrite(false); | 3779 | m_host.TaskInventory.LockItemsForWrite(false); |
3861 | 3780 | ||
3862 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3781 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
@@ -3864,7 +3783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3864 | } | 3783 | } |
3865 | 3784 | ||
3866 | presence.ControllingClient.SendScriptQuestion( | 3785 | presence.ControllingClient.SendScriptQuestion( |
3867 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); | 3786 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm); |
3868 | 3787 | ||
3869 | return; | 3788 | return; |
3870 | } | 3789 | } |
@@ -3881,23 +3800,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3881 | if (taskID != m_host.UUID) | 3800 | if (taskID != m_host.UUID) |
3882 | return; | 3801 | return; |
3883 | 3802 | ||
3884 | UUID invItemID = InventorySelf(); | 3803 | client.OnScriptAnswer -= handleScriptAnswer; |
3885 | 3804 | m_waitingForScriptAnswer = false; | |
3886 | if (invItemID == UUID.Zero) | ||
3887 | return; | ||
3888 | |||
3889 | client.OnScriptAnswer-=handleScriptAnswer; | ||
3890 | m_waitingForScriptAnswer=false; | ||
3891 | 3805 | ||
3892 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3806 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3893 | llReleaseControls(); | 3807 | llReleaseControls(); |
3894 | 3808 | ||
3895 | |||
3896 | m_host.TaskInventory.LockItemsForWrite(true); | 3809 | m_host.TaskInventory.LockItemsForWrite(true); |
3897 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3810 | m_host.TaskInventory[m_itemID].PermsMask = answer; |
3898 | m_host.TaskInventory.LockItemsForWrite(false); | 3811 | m_host.TaskInventory.LockItemsForWrite(false); |
3899 | 3812 | ||
3900 | |||
3901 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3813 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3902 | "run_time_permissions", new Object[] { | 3814 | "run_time_permissions", new Object[] { |
3903 | new LSL_Integer(answer) }, | 3815 | new LSL_Integer(answer) }, |
@@ -3908,41 +3820,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3908 | { | 3820 | { |
3909 | m_host.AddScriptLPS(1); | 3821 | m_host.AddScriptLPS(1); |
3910 | 3822 | ||
3911 | m_host.TaskInventory.LockItemsForRead(true); | 3823 | return GetSelfInventoryItem().PermsGranter.ToString(); |
3912 | |||
3913 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3914 | { | ||
3915 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3916 | { | ||
3917 | m_host.TaskInventory.LockItemsForRead(false); | ||
3918 | return item.PermsGranter.ToString(); | ||
3919 | } | ||
3920 | } | ||
3921 | m_host.TaskInventory.LockItemsForRead(false); | ||
3922 | |||
3923 | return UUID.Zero.ToString(); | ||
3924 | } | 3824 | } |
3925 | 3825 | ||
3926 | public LSL_Integer llGetPermissions() | 3826 | public LSL_Integer llGetPermissions() |
3927 | { | 3827 | { |
3928 | m_host.AddScriptLPS(1); | 3828 | m_host.AddScriptLPS(1); |
3929 | 3829 | ||
3930 | m_host.TaskInventory.LockItemsForRead(true); | 3830 | int perms = GetSelfInventoryItem().PermsMask; |
3931 | 3831 | ||
3932 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3832 | if (m_automaticLinkPermission) |
3933 | { | 3833 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3934 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3935 | { | ||
3936 | int perms = item.PermsMask; | ||
3937 | if (m_automaticLinkPermission) | ||
3938 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | ||
3939 | m_host.TaskInventory.LockItemsForRead(false); | ||
3940 | return perms; | ||
3941 | } | ||
3942 | } | ||
3943 | m_host.TaskInventory.LockItemsForRead(false); | ||
3944 | 3834 | ||
3945 | return 0; | 3835 | return perms; |
3946 | } | 3836 | } |
3947 | 3837 | ||
3948 | public LSL_Integer llGetLinkNumber() | 3838 | public LSL_Integer llGetLinkNumber() |
@@ -3980,17 +3870,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3980 | public void llCreateLink(string target, int parent) | 3870 | public void llCreateLink(string target, int parent) |
3981 | { | 3871 | { |
3982 | m_host.AddScriptLPS(1); | 3872 | m_host.AddScriptLPS(1); |
3983 | UUID invItemID = InventorySelf(); | 3873 | |
3984 | UUID targetID; | 3874 | UUID targetID; |
3985 | 3875 | ||
3986 | if (!UUID.TryParse(target, out targetID)) | 3876 | if (!UUID.TryParse(target, out targetID)) |
3987 | return; | 3877 | return; |
3988 | 3878 | ||
3989 | TaskInventoryItem item; | 3879 | TaskInventoryItem item = GetSelfInventoryItem(); |
3990 | m_host.TaskInventory.LockItemsForRead(true); | 3880 | |
3991 | item = m_host.TaskInventory[invItemID]; | ||
3992 | m_host.TaskInventory.LockItemsForRead(false); | ||
3993 | |||
3994 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3881 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3995 | && !m_automaticLinkPermission) | 3882 | && !m_automaticLinkPermission) |
3996 | { | 3883 | { |
@@ -4045,18 +3932,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4045 | public void llBreakLink(int linknum) | 3932 | public void llBreakLink(int linknum) |
4046 | { | 3933 | { |
4047 | m_host.AddScriptLPS(1); | 3934 | m_host.AddScriptLPS(1); |
4048 | UUID invItemID = InventorySelf(); | ||
4049 | 3935 | ||
4050 | m_host.TaskInventory.LockItemsForRead(true); | 3936 | if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4051 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3937 | && !m_automaticLinkPermission) |
4052 | && !m_automaticLinkPermission) | 3938 | { |
4053 | { | 3939 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
4054 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3940 | return; |
4055 | m_host.TaskInventory.LockItemsForRead(false); | 3941 | } |
4056 | return; | 3942 | |
4057 | } | ||
4058 | m_host.TaskInventory.LockItemsForRead(false); | ||
4059 | |||
4060 | if (linknum < ScriptBaseClass.LINK_THIS) | 3943 | if (linknum < ScriptBaseClass.LINK_THIS) |
4061 | return; | 3944 | return; |
4062 | 3945 | ||
@@ -4155,12 +4038,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4155 | { | 4038 | { |
4156 | m_host.AddScriptLPS(1); | 4039 | m_host.AddScriptLPS(1); |
4157 | 4040 | ||
4158 | UUID invItemID = InventorySelf(); | 4041 | TaskInventoryItem item = GetSelfInventoryItem(); |
4159 | |||
4160 | TaskInventoryItem item; | ||
4161 | m_host.TaskInventory.LockItemsForRead(true); | ||
4162 | item = m_host.TaskInventory[invItemID]; | ||
4163 | m_host.TaskInventory.LockItemsForRead(false); | ||
4164 | 4042 | ||
4165 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 4043 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4166 | && !m_automaticLinkPermission) | 4044 | && !m_automaticLinkPermission) |
@@ -5033,22 +4911,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5033 | 4911 | ||
5034 | public LSL_String llGetScriptName() | 4912 | public LSL_String llGetScriptName() |
5035 | { | 4913 | { |
5036 | string result = String.Empty; | ||
5037 | |||
5038 | m_host.AddScriptLPS(1); | 4914 | m_host.AddScriptLPS(1); |
5039 | 4915 | ||
5040 | m_host.TaskInventory.LockItemsForRead(true); | 4916 | TaskInventoryItem item = GetSelfInventoryItem(); |
5041 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
5042 | { | ||
5043 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
5044 | { | ||
5045 | result = item.Name!=null?item.Name:String.Empty; | ||
5046 | break; | ||
5047 | } | ||
5048 | } | ||
5049 | m_host.TaskInventory.LockItemsForRead(false); | ||
5050 | 4917 | ||
5051 | return result; | 4918 | return item.Name != null ? item.Name : String.Empty; |
5052 | } | 4919 | } |
5053 | 4920 | ||
5054 | public LSL_Integer llGetLinkNumberOfSides(int link) | 4921 | public LSL_Integer llGetLinkNumberOfSides(int link) |
@@ -6248,7 +6115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6248 | if (m_host.OwnerID == land.LandData.OwnerID) | 6115 | if (m_host.OwnerID == land.LandData.OwnerID) |
6249 | { | 6116 | { |
6250 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); | 6117 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6251 | presence.TeleportWithMomentum(pos); | 6118 | presence.TeleportWithMomentum(pos, null); |
6252 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | 6119 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); |
6253 | } | 6120 | } |
6254 | } | 6121 | } |
@@ -9990,7 +9857,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9990 | // child agents have a mass of 1.0 | 9857 | // child agents have a mass of 1.0 |
9991 | return 1; | 9858 | return 1; |
9992 | else | 9859 | else |
9993 | return avatar.GetMass(); | 9860 | return (double)avatar.GetMass(); |
9994 | } | 9861 | } |
9995 | catch (KeyNotFoundException) | 9862 | catch (KeyNotFoundException) |
9996 | { | 9863 | { |
@@ -10433,22 +10300,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10433 | public LSL_Vector llGetCameraPos() | 10300 | public LSL_Vector llGetCameraPos() |
10434 | { | 10301 | { |
10435 | m_host.AddScriptLPS(1); | 10302 | m_host.AddScriptLPS(1); |
10436 | UUID invItemID = InventorySelf(); | ||
10437 | 10303 | ||
10438 | if (invItemID == UUID.Zero) | 10304 | TaskInventoryItem item = GetSelfInventoryItem(); |
10439 | return new LSL_Vector(); | ||
10440 | 10305 | ||
10441 | m_host.TaskInventory.LockItemsForRead(true); | 10306 | if (item.PermsGranter == UUID.Zero) |
10442 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 10307 | return new LSL_Vector(); |
10443 | { | ||
10444 | m_host.TaskInventory.LockItemsForRead(false); | ||
10445 | return new LSL_Vector(); | ||
10446 | } | ||
10447 | 10308 | ||
10448 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 10309 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10449 | { | 10310 | { |
10450 | ShoutError("No permissions to track the camera"); | 10311 | ShoutError("No permissions to track the camera"); |
10451 | m_host.TaskInventory.LockItemsForRead(false); | ||
10452 | return new LSL_Vector(); | 10312 | return new LSL_Vector(); |
10453 | } | 10313 | } |
10454 | m_host.TaskInventory.LockItemsForRead(false); | 10314 | m_host.TaskInventory.LockItemsForRead(false); |
@@ -10465,20 +10325,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10465 | public LSL_Rotation llGetCameraRot() | 10325 | public LSL_Rotation llGetCameraRot() |
10466 | { | 10326 | { |
10467 | m_host.AddScriptLPS(1); | 10327 | m_host.AddScriptLPS(1); |
10468 | UUID invItemID = InventorySelf(); | ||
10469 | if (invItemID == UUID.Zero) | ||
10470 | return new LSL_Rotation(); | ||
10471 | 10328 | ||
10472 | m_host.TaskInventory.LockItemsForRead(true); | 10329 | TaskInventoryItem item = GetSelfInventoryItem(); |
10473 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 10330 | |
10474 | { | 10331 | if (item.PermsGranter == UUID.Zero) |
10475 | m_host.TaskInventory.LockItemsForRead(false); | 10332 | return new LSL_Rotation(); |
10476 | return new LSL_Rotation(); | 10333 | |
10477 | } | 10334 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10478 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
10479 | { | 10335 | { |
10480 | ShoutError("No permissions to track the camera"); | 10336 | ShoutError("No permissions to track the camera"); |
10481 | m_host.TaskInventory.LockItemsForRead(false); | ||
10482 | return new LSL_Rotation(); | 10337 | return new LSL_Rotation(); |
10483 | } | 10338 | } |
10484 | m_host.TaskInventory.LockItemsForRead(false); | 10339 | m_host.TaskInventory.LockItemsForRead(false); |
@@ -10666,30 +10521,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10666 | { | 10521 | { |
10667 | m_host.AddScriptLPS(1); | 10522 | m_host.AddScriptLPS(1); |
10668 | 10523 | ||
10669 | // our key in the object we are in | ||
10670 | UUID invItemID = InventorySelf(); | ||
10671 | if (invItemID == UUID.Zero) return; | ||
10672 | |||
10673 | // the object we are in | 10524 | // the object we are in |
10674 | UUID objectID = m_host.ParentUUID; | 10525 | UUID objectID = m_host.ParentUUID; |
10675 | if (objectID == UUID.Zero) return; | 10526 | if (objectID == UUID.Zero) |
10527 | return; | ||
10528 | |||
10529 | TaskInventoryItem item = GetSelfInventoryItem(); | ||
10676 | 10530 | ||
10677 | UUID agentID; | ||
10678 | m_host.TaskInventory.LockItemsForRead(true); | ||
10679 | // we need the permission first, to know which avatar we want to set the camera for | 10531 | // we need the permission first, to know which avatar we want to set the camera for |
10680 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10532 | UUID agentID = item.PermsGranter; |
10681 | 10533 | ||
10682 | if (agentID == UUID.Zero) | 10534 | if (agentID == UUID.Zero) |
10683 | { | ||
10684 | m_host.TaskInventory.LockItemsForRead(false); | ||
10685 | return; | 10535 | return; |
10686 | } | 10536 | |
10687 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10537 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10688 | { | ||
10689 | m_host.TaskInventory.LockItemsForRead(false); | ||
10690 | return; | 10538 | return; |
10691 | } | ||
10692 | m_host.TaskInventory.LockItemsForRead(false); | ||
10693 | 10539 | ||
10694 | ScenePresence presence = World.GetScenePresence(agentID); | 10540 | ScenePresence presence = World.GetScenePresence(agentID); |
10695 | 10541 | ||
@@ -10731,34 +10577,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10731 | { | 10577 | { |
10732 | m_host.AddScriptLPS(1); | 10578 | m_host.AddScriptLPS(1); |
10733 | 10579 | ||
10734 | // our key in the object we are in | ||
10735 | UUID invItemID=InventorySelf(); | ||
10736 | if (invItemID == UUID.Zero) return; | ||
10737 | |||
10738 | // the object we are in | 10580 | // the object we are in |
10739 | UUID objectID = m_host.ParentUUID; | 10581 | UUID objectID = m_host.ParentUUID; |
10740 | if (objectID == UUID.Zero) return; | 10582 | if (objectID == UUID.Zero) |
10583 | return; | ||
10584 | |||
10585 | TaskInventoryItem item = GetSelfInventoryItem(); | ||
10741 | 10586 | ||
10742 | // we need the permission first, to know which avatar we want to clear the camera for | 10587 | // we need the permission first, to know which avatar we want to clear the camera for |
10743 | UUID agentID; | 10588 | UUID agentID = item.PermsGranter; |
10744 | m_host.TaskInventory.LockItemsForRead(true); | 10589 | |
10745 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10746 | if (agentID == UUID.Zero) | 10590 | if (agentID == UUID.Zero) |
10747 | { | ||
10748 | m_host.TaskInventory.LockItemsForRead(false); | ||
10749 | return; | 10591 | return; |
10750 | } | 10592 | |
10751 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10593 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10752 | { | ||
10753 | m_host.TaskInventory.LockItemsForRead(false); | ||
10754 | return; | 10594 | return; |
10755 | } | ||
10756 | m_host.TaskInventory.LockItemsForRead(false); | ||
10757 | 10595 | ||
10758 | ScenePresence presence = World.GetScenePresence(agentID); | 10596 | ScenePresence presence = World.GetScenePresence(agentID); |
10759 | 10597 | ||
10760 | // we are not interested in child-agents | 10598 | // we are not interested in child-agents |
10761 | if (presence.IsChildAgent) return; | 10599 | if (presence.IsChildAgent) |
10600 | return; | ||
10762 | 10601 | ||
10763 | presence.ControllingClient.SendClearFollowCamProperties(objectID); | 10602 | presence.ControllingClient.SendClearFollowCamProperties(objectID); |
10764 | } | 10603 | } |
@@ -11182,19 +11021,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11182 | break; | 11021 | break; |
11183 | // For the following 8 see the Object version below | 11022 | // For the following 8 see the Object version below |
11184 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11023 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11185 | ret.Add(new LSL_Integer(0)); | 11024 | ret.Add(new LSL_Integer(av.RunningScriptCount())); |
11186 | break; | 11025 | break; |
11187 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11026 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11188 | ret.Add(new LSL_Integer(0)); | 11027 | ret.Add(new LSL_Integer(av.ScriptCount())); |
11189 | break; | 11028 | break; |
11190 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11029 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11191 | ret.Add(new LSL_Integer(0)); | 11030 | ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384)); |
11192 | break; | 11031 | break; |
11193 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11032 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11194 | ret.Add(new LSL_Float(0)); | 11033 | ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f)); |
11195 | break; | 11034 | break; |
11196 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11035 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11197 | ret.Add(new LSL_Integer(0)); | 11036 | ret.Add(new LSL_Integer(1)); |
11198 | break; | 11037 | break; |
11199 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11038 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11200 | ret.Add(new LSL_Float(0)); | 11039 | ret.Add(new LSL_Float(0)); |
@@ -11246,43 +11085,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11246 | case ScriptBaseClass.OBJECT_CREATOR: | 11085 | case ScriptBaseClass.OBJECT_CREATOR: |
11247 | ret.Add(new LSL_String(obj.CreatorID.ToString())); | 11086 | ret.Add(new LSL_String(obj.CreatorID.ToString())); |
11248 | break; | 11087 | break; |
11249 | // The following 8 I have intentionaly coded to return zero. They are part of | ||
11250 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11251 | // to OpenSim, required figures (cpu/memory usage) are not currently tracked | ||
11252 | // I have intentionally left these all at zero rather than return possibly | ||
11253 | // missleading numbers | ||
11254 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11088 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11255 | // in SL this currently includes crashed scripts | 11089 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount())); |
11256 | ret.Add(new LSL_Integer(0)); | ||
11257 | break; | 11090 | break; |
11258 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11091 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11259 | ret.Add(new LSL_Integer(0)); | 11092 | ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount())); |
11260 | break; | 11093 | break; |
11261 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11094 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11262 | // The value returned in SL for mono scripts is 65536 * number of active scripts | 11095 | // The value returned in SL for mono scripts is 65536 * number of active scripts |
11263 | ret.Add(new LSL_Integer(0)); | 11096 | // and 16384 * number of active scripts for LSO. since llGetFreememory |
11097 | // is coded to give the LSO value use it here | ||
11098 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384)); | ||
11264 | break; | 11099 | break; |
11265 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11100 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11266 | // Average cpu time per simulator frame expended on all scripts in the objetc | 11101 | // Average cpu time in seconds per simulator frame expended on all scripts in the object |
11267 | ret.Add(new LSL_Float(0)); | 11102 | ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f)); |
11268 | break; | 11103 | break; |
11269 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11104 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11270 | // according to the SL wiki A prim or linkset will have prim | 11105 | // according to the SL wiki A prim or linkset will have prim |
11271 | // equivalent of the number of prims in a linkset if it does not | 11106 | // equivalent of the number of prims in a linkset if it does not |
11272 | // contain a mesh anywhere in the link set or is not a normal prim | 11107 | // contain a mesh anywhere in the link set or is not a normal prim |
11273 | // The value returned in SL for normal prims is prim count | 11108 | // The value returned in SL for normal prims is prim count |
11274 | ret.Add(new LSL_Integer(0)); | 11109 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
11275 | break; | 11110 | break; |
11111 | // The following 3 costs I have intentionaly coded to return zero. They are part of | ||
11112 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11113 | // to OpenSim and are not yet complete in SL | ||
11276 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11114 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11277 | // The value returned in SL for normal prims is prim count | 11115 | // The linden calculation is here |
11116 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | ||
11117 | // The value returned in SL for normal prims looks like the prim count | ||
11278 | ret.Add(new LSL_Float(0)); | 11118 | ret.Add(new LSL_Float(0)); |
11279 | break; | 11119 | break; |
11280 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 11120 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
11281 | // The value returned in SL for normal prims is prim count * 0.06 | 11121 | // The linden calculation is here |
11122 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | ||
11123 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
11282 | ret.Add(new LSL_Float(0)); | 11124 | ret.Add(new LSL_Float(0)); |
11283 | break; | 11125 | break; |
11284 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 11126 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
11285 | // The value returned in SL for normal prims is prim count | 11127 | // The linden calculation is here |
11128 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | ||
11129 | // The value returned in SL for normal prims looks like the prim count | ||
11286 | ret.Add(new LSL_Float(0)); | 11130 | ret.Add(new LSL_Float(0)); |
11287 | break; | 11131 | break; |
11288 | default: | 11132 | default: |
@@ -12037,7 +11881,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12037 | bool isAccount = false; | 11881 | bool isAccount = false; |
12038 | bool isGroup = false; | 11882 | bool isGroup = false; |
12039 | 11883 | ||
12040 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) | 11884 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) |
12041 | return 0; | 11885 | return 0; |
12042 | 11886 | ||
12043 | UUID id = new UUID(); | 11887 | UUID id = new UUID(); |
@@ -12099,35 +11943,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12099 | return 1; | 11943 | return 1; |
12100 | } | 11944 | } |
12101 | 11945 | ||
12102 | #region Not Implemented | 11946 | public LSL_Integer llGetMemoryLimit() |
12103 | // | 11947 | { |
12104 | // Listing the unimplemented lsl functions here, please move | 11948 | m_host.AddScriptLPS(1); |
12105 | // them from this region as they are completed | 11949 | // The value returned for LSO scripts in SL |
12106 | // | 11950 | return 16384; |
11951 | } | ||
12107 | 11952 | ||
12108 | public void llGetEnv(LSL_String name) | 11953 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) |
12109 | { | 11954 | { |
12110 | m_host.AddScriptLPS(1); | 11955 | m_host.AddScriptLPS(1); |
12111 | NotImplemented("llGetEnv"); | 11956 | // Treat as an LSO script |
11957 | return ScriptBaseClass.FALSE; | ||
12112 | } | 11958 | } |
12113 | 11959 | ||
12114 | public void llGetSPMaxMemory() | 11960 | public LSL_Integer llGetSPMaxMemory() |
12115 | { | 11961 | { |
12116 | m_host.AddScriptLPS(1); | 11962 | m_host.AddScriptLPS(1); |
12117 | NotImplemented("llGetSPMaxMemory"); | 11963 | // The value returned for LSO scripts in SL |
11964 | return 16384; | ||
12118 | } | 11965 | } |
12119 | 11966 | ||
12120 | public virtual LSL_Integer llGetUsedMemory() | 11967 | public virtual LSL_Integer llGetUsedMemory() |
12121 | { | 11968 | { |
12122 | m_host.AddScriptLPS(1); | 11969 | m_host.AddScriptLPS(1); |
12123 | NotImplemented("llGetUsedMemory"); | 11970 | // The value returned for LSO scripts in SL |
12124 | return 0; | 11971 | return 16384; |
12125 | } | 11972 | } |
12126 | 11973 | ||
12127 | public void llScriptProfiler(LSL_Integer flags) | 11974 | public void llScriptProfiler(LSL_Integer flags) |
12128 | { | 11975 | { |
12129 | m_host.AddScriptLPS(1); | 11976 | m_host.AddScriptLPS(1); |
12130 | //NotImplemented("llScriptProfiler"); | 11977 | // This does nothing for LSO scripts in SL |
11978 | } | ||
11979 | |||
11980 | #region Not Implemented | ||
11981 | // | ||
11982 | // Listing the unimplemented lsl functions here, please move | ||
11983 | // them from this region as they are completed | ||
11984 | // | ||
11985 | |||
11986 | public void llGetEnv(LSL_String name) | ||
11987 | { | ||
11988 | m_host.AddScriptLPS(1); | ||
11989 | NotImplemented("llGetEnv"); | ||
12131 | } | 11990 | } |
12132 | 11991 | ||
12133 | public void llSetSoundQueueing(int queue) | 11992 | public void llSetSoundQueueing(int queue) |
@@ -12207,8 +12066,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12207 | 12066 | ||
12208 | try | 12067 | try |
12209 | { | 12068 | { |
12210 | UUID invItemID=InventorySelf(); | 12069 | TaskInventoryItem item = GetSelfInventoryItem(); |
12211 | if (invItemID == UUID.Zero) | 12070 | if (item == null) |
12212 | { | 12071 | { |
12213 | replydata = "SERVICE_ERROR"; | 12072 | replydata = "SERVICE_ERROR"; |
12214 | return; | 12073 | return; |
@@ -12216,10 +12075,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12216 | 12075 | ||
12217 | m_host.AddScriptLPS(1); | 12076 | m_host.AddScriptLPS(1); |
12218 | 12077 | ||
12219 | m_host.TaskInventory.LockItemsForRead(true); | ||
12220 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
12221 | m_host.TaskInventory.LockItemsForRead(false); | ||
12222 | |||
12223 | if (item.PermsGranter == UUID.Zero) | 12078 | if (item.PermsGranter == UUID.Zero) |
12224 | { | 12079 | { |
12225 | replydata = "MISSING_PERMISSION_DEBIT"; | 12080 | replydata = "MISSING_PERMISSION_DEBIT"; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 77a784d..df20126 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -449,7 +449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
449 | LSShoutError("LightShare functions are not enabled."); | 449 | LSShoutError("LightShare functions are not enabled."); |
450 | return 0; | 450 | return 0; |
451 | } | 451 | } |
452 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 452 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
453 | { | 453 | { |
454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
455 | return 0; | 455 | return 0; |
@@ -477,7 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
477 | LSShoutError("LightShare functions are not enabled."); | 477 | LSShoutError("LightShare functions are not enabled."); |
478 | return; | 478 | return; |
479 | } | 479 | } |
480 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 480 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
481 | { | 481 | { |
482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
483 | return; | 483 | return; |
@@ -500,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
500 | LSShoutError("LightShare functions are not enabled."); | 500 | LSShoutError("LightShare functions are not enabled."); |
501 | return 0; | 501 | return 0; |
502 | } | 502 | } |
503 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 503 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
504 | { | 504 | { |
505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | 505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); |
506 | return 0; | 506 | return 0; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0dc2aa2..60568a8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -218,6 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /// <summary> | ||
222 | /// Initialize the LSL interface. | ||
223 | /// </summary> | ||
224 | /// <remarks> | ||
225 | /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no | ||
226 | /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from | ||
227 | /// ScriptInstance. | ||
228 | /// </remarks> | ||
221 | private void InitLSL() | 229 | private void InitLSL() |
222 | { | 230 | { |
223 | if (m_LSL_Api != null) | 231 | if (m_LSL_Api != null) |
@@ -352,7 +360,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
352 | 360 | ||
353 | UUID ownerID = ti.OwnerID; | 361 | UUID ownerID = ti.OwnerID; |
354 | 362 | ||
355 | //OSSL only may be used if objet is in the same group as the parcel | 363 | //OSSL only may be used if object is in the same group as the parcel |
356 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) | 364 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) |
357 | { | 365 | { |
358 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 366 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); |
@@ -378,7 +386,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
378 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) | 386 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) |
379 | { | 387 | { |
380 | //Only Estate Managers may use the function | 388 | //Only Estate Managers may use the function |
381 | if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) | 389 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) |
382 | { | 390 | { |
383 | return; | 391 | return; |
384 | } | 392 | } |
@@ -730,11 +738,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
730 | 738 | ||
731 | m_host.AddScriptLPS(1); | 739 | m_host.AddScriptLPS(1); |
732 | 740 | ||
741 | // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions | ||
733 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 742 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) |
734 | { | 743 | { |
735 | MainConsole.Instance.RunCommand(command); | 744 | MainConsole.Instance.RunCommand(command); |
736 | return true; | 745 | return true; |
737 | } | 746 | } |
747 | |||
738 | return false; | 748 | return false; |
739 | } | 749 | } |
740 | 750 | ||
@@ -1186,12 +1196,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1186 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); | 1196 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); |
1187 | 1197 | ||
1188 | m_host.AddScriptLPS(1); | 1198 | m_host.AddScriptLPS(1); |
1189 | //Check to make sure that the script's owner is the estate manager/master | 1199 | |
1190 | //World.Permissions.GenericEstatePermission( | 1200 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); |
1191 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1192 | { | ||
1193 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); | ||
1194 | } | ||
1195 | } | 1201 | } |
1196 | 1202 | ||
1197 | /// <summary> | 1203 | /// <summary> |
@@ -1202,27 +1208,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1202 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | 1208 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> |
1203 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) | 1209 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) |
1204 | { | 1210 | { |
1205 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); | 1211 | CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); |
1206 | 1212 | ||
1207 | m_host.AddScriptLPS(1); | 1213 | m_host.AddScriptLPS(1); |
1208 | //Check to make sure that the script's owner is the estate manager/master | ||
1209 | //World.Permissions.GenericEstatePermission( | ||
1210 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1211 | { | ||
1212 | while (sunHour > 24.0) | ||
1213 | sunHour -= 24.0; | ||
1214 | 1214 | ||
1215 | while (sunHour < 0) | 1215 | while (sunHour > 24.0) |
1216 | sunHour += 24.0; | 1216 | sunHour -= 24.0; |
1217 | 1217 | ||
1218 | while (sunHour < 0) | ||
1219 | sunHour += 24.0; | ||
1218 | 1220 | ||
1219 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 1221 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
1220 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 1222 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
1221 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 1223 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
1222 | World.RegionInfo.RegionSettings.Save(); | 1224 | World.RegionInfo.RegionSettings.Save(); |
1223 | 1225 | ||
1224 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); | 1226 | World.EventManager.TriggerEstateToolsSunUpdate( |
1225 | } | 1227 | World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); |
1226 | } | 1228 | } |
1227 | 1229 | ||
1228 | /// <summary> | 1230 | /// <summary> |
@@ -1232,26 +1234,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1232 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | 1234 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> |
1233 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) | 1235 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) |
1234 | { | 1236 | { |
1235 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); | 1237 | CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); |
1236 | 1238 | ||
1237 | m_host.AddScriptLPS(1); | 1239 | m_host.AddScriptLPS(1); |
1238 | //Check to make sure that the script's owner is the estate manager/master | ||
1239 | //World.Permissions.GenericEstatePermission( | ||
1240 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1241 | { | ||
1242 | while (sunHour > 24.0) | ||
1243 | sunHour -= 24.0; | ||
1244 | 1240 | ||
1245 | while (sunHour < 0) | 1241 | while (sunHour > 24.0) |
1246 | sunHour += 24.0; | 1242 | sunHour -= 24.0; |
1247 | 1243 | ||
1248 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | 1244 | while (sunHour < 0) |
1249 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | 1245 | sunHour += 24.0; |
1250 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1251 | World.RegionInfo.EstateSettings.Save(); | ||
1252 | 1246 | ||
1253 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | 1247 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; |
1254 | } | 1248 | World.RegionInfo.EstateSettings.SunPosition = sunHour; |
1249 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1250 | World.RegionInfo.EstateSettings.Save(); | ||
1251 | |||
1252 | World.EventManager.TriggerEstateToolsSunUpdate( | ||
1253 | World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
1255 | } | 1254 | } |
1256 | 1255 | ||
1257 | /// <summary> | 1256 | /// <summary> |
@@ -1627,7 +1626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1627 | 1626 | ||
1628 | public Object osParseJSONNew(string JSON) | 1627 | public Object osParseJSONNew(string JSON) |
1629 | { | 1628 | { |
1630 | CheckThreatLevel(ThreatLevel.None, "osParseJSON"); | 1629 | CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); |
1631 | 1630 | ||
1632 | m_host.AddScriptLPS(1); | 1631 | m_host.AddScriptLPS(1); |
1633 | 1632 | ||
@@ -2555,7 +2554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2554 | ||
2556 | public void osNpcStopMoveToTarget(LSL_Key npc) | 2555 | public void osNpcStopMoveToTarget(LSL_Key npc) |
2557 | { | 2556 | { |
2558 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | 2557 | CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); |
2559 | m_host.AddScriptLPS(1); | 2558 | m_host.AddScriptLPS(1); |
2560 | 2559 | ||
2561 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2560 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
@@ -2572,6 +2571,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2572 | 2571 | ||
2573 | public void osNpcSay(LSL_Key npc, string message) | 2572 | public void osNpcSay(LSL_Key npc, string message) |
2574 | { | 2573 | { |
2574 | osNpcSay(npc, 0, message); | ||
2575 | } | ||
2576 | |||
2577 | public void osNpcSay(LSL_Key npc, int channel, string message) | ||
2578 | { | ||
2575 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2579 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
2576 | m_host.AddScriptLPS(1); | 2580 | m_host.AddScriptLPS(1); |
2577 | 2581 | ||
@@ -2583,7 +2587,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2583 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2587 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2584 | return; | 2588 | return; |
2585 | 2589 | ||
2586 | module.Say(npcId, World, message); | 2590 | module.Say(npcId, World, message, channel); |
2591 | } | ||
2592 | } | ||
2593 | |||
2594 | public void osNpcShout(LSL_Key npc, int channel, string message) | ||
2595 | { | ||
2596 | CheckThreatLevel(ThreatLevel.High, "osNpcShout"); | ||
2597 | m_host.AddScriptLPS(1); | ||
2598 | |||
2599 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2600 | if (module != null) | ||
2601 | { | ||
2602 | UUID npcId = new UUID(npc.m_string); | ||
2603 | |||
2604 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2605 | return; | ||
2606 | |||
2607 | module.Shout(npcId, World, message, channel); | ||
2587 | } | 2608 | } |
2588 | } | 2609 | } |
2589 | 2610 | ||
@@ -2684,6 +2705,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2684 | } | 2705 | } |
2685 | } | 2706 | } |
2686 | 2707 | ||
2708 | public void osNpcWhisper(LSL_Key npc, int channel, string message) | ||
2709 | { | ||
2710 | CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); | ||
2711 | m_host.AddScriptLPS(1); | ||
2712 | |||
2713 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2714 | if (module != null) | ||
2715 | { | ||
2716 | UUID npcId = new UUID(npc.m_string); | ||
2717 | |||
2718 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2719 | return; | ||
2720 | |||
2721 | module.Whisper(npcId, World, message, channel); | ||
2722 | } | ||
2723 | } | ||
2724 | |||
2687 | /// <summary> | 2725 | /// <summary> |
2688 | /// Save the current appearance of the script owner permanently to the named notecard. | 2726 | /// Save the current appearance of the script owner permanently to the named notecard. |
2689 | /// </summary> | 2727 | /// </summary> |
@@ -2835,21 +2873,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2835 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 2873 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2836 | m_host.AddScriptLPS(1); | 2874 | m_host.AddScriptLPS(1); |
2837 | 2875 | ||
2838 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 2876 | World.ForEachRootScenePresence(delegate(ScenePresence sp) |
2839 | { | 2877 | { |
2840 | World.ForEachRootScenePresence(delegate(ScenePresence sp) | 2878 | if (sp.Firstname == FirstName && sp.Lastname == SurName) |
2841 | { | 2879 | { |
2842 | if (sp.Firstname == FirstName && sp.Lastname == SurName) | 2880 | // kick client... |
2843 | { | 2881 | if (alert != null) |
2844 | // kick client... | 2882 | sp.ControllingClient.Kick(alert); |
2845 | if (alert != null) | ||
2846 | sp.ControllingClient.Kick(alert); | ||
2847 | 2883 | ||
2848 | // ...and close on our side | 2884 | // ...and close on our side |
2849 | sp.Scene.IncomingCloseAgent(sp.UUID); | 2885 | sp.Scene.IncomingCloseAgent(sp.UUID); |
2850 | } | 2886 | } |
2851 | }); | 2887 | }); |
2852 | } | ||
2853 | } | 2888 | } |
2854 | 2889 | ||
2855 | public void osCauseDamage(string avatar, double damage) | 2890 | public void osCauseDamage(string avatar, double damage) |
@@ -3095,5 +3130,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3095 | 3130 | ||
3096 | return ScriptBaseClass.TRUE; | 3131 | return ScriptBaseClass.TRUE; |
3097 | } | 3132 | } |
3133 | |||
3134 | /// <summary> | ||
3135 | /// Sets terrain estate texture | ||
3136 | /// </summary> | ||
3137 | /// <param name="level"></param> | ||
3138 | /// <param name="texture"></param> | ||
3139 | /// <returns></returns> | ||
3140 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
3141 | { | ||
3142 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); | ||
3143 | |||
3144 | m_host.AddScriptLPS(1); | ||
3145 | //Check to make sure that the script's owner is the estate manager/master | ||
3146 | //World.Permissions.GenericEstatePermission( | ||
3147 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3148 | { | ||
3149 | if (level < 0 || level > 3) | ||
3150 | return; | ||
3151 | |||
3152 | UUID textureID = new UUID(); | ||
3153 | if (!UUID.TryParse(texture, out textureID)) | ||
3154 | return; | ||
3155 | |||
3156 | // estate module is required | ||
3157 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3158 | if (estate != null) | ||
3159 | estate.setEstateTerrainBaseTexture(level, textureID); | ||
3160 | } | ||
3161 | } | ||
3162 | |||
3163 | /// <summary> | ||
3164 | /// Sets terrain heights of estate | ||
3165 | /// </summary> | ||
3166 | /// <param name="corner"></param> | ||
3167 | /// <param name="low"></param> | ||
3168 | /// <param name="high"></param> | ||
3169 | /// <returns></returns> | ||
3170 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
3171 | { | ||
3172 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); | ||
3173 | |||
3174 | m_host.AddScriptLPS(1); | ||
3175 | //Check to make sure that the script's owner is the estate manager/master | ||
3176 | //World.Permissions.GenericEstatePermission( | ||
3177 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3178 | { | ||
3179 | if (corner < 0 || corner > 3) | ||
3180 | return; | ||
3181 | |||
3182 | // estate module is required | ||
3183 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3184 | if (estate != null) | ||
3185 | estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); | ||
3186 | } | ||
3187 | } | ||
3188 | |||
3189 | public void osForceAttachToAvatar(int attachmentPoint) | ||
3190 | { | ||
3191 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); | ||
3192 | |||
3193 | m_host.AddScriptLPS(1); | ||
3194 | |||
3195 | InitLSL(); | ||
3196 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | ||
3197 | } | ||
3198 | |||
3199 | public void osForceDetachFromAvatar() | ||
3200 | { | ||
3201 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | ||
3202 | |||
3203 | m_host.AddScriptLPS(1); | ||
3204 | |||
3205 | InitLSL(); | ||
3206 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | ||
3207 | } | ||
3098 | } | 3208 | } |
3099 | } | 3209 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 1373971..19f3ce1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
308 | } | 308 | } |
309 | SceneObjectPart SensePoint = ts.host; | 309 | SceneObjectPart SensePoint = ts.host; |
310 | 310 | ||
311 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 311 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
312 | 312 | ||
313 | // pre define some things to avoid repeated definitions in the loop body | 313 | // pre define some things to avoid repeated definitions in the loop body |
314 | Vector3 toRegionPos; | 314 | Vector3 toRegionPos; |
@@ -323,13 +323,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | 323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! |
324 | if (SensePoint.ParentGroup.IsAttachment) | 324 | if (SensePoint.ParentGroup.IsAttachment) |
325 | { | 325 | { |
326 | // In attachments, the sensor cone always orients with the | 326 | // In attachments, rotate the sensor cone with the |
327 | // avatar rotation. This may include a nonzero elevation if | 327 | // avatar rotation. This may include a nonzero elevation if |
328 | // in mouselook. | 328 | // in mouselook. |
329 | // This will not include the rotation and position of the | ||
330 | // attachment point (e.g. your head when a sensor is in your | ||
331 | // hair attached to your scull. Your hair will turn with | ||
332 | // your head but the sensor will stay with your (global) | ||
333 | // avatar rotation and position. | ||
334 | // Position of a sensor in a child prim attached to an avatar | ||
335 | // will be still wrong. | ||
329 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 336 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
330 | fromRegionPos = avatar.AbsolutePosition; | 337 | fromRegionPos = avatar.AbsolutePosition; |
331 | q = avatar.Rotation; | 338 | q = avatar.Rotation; |
332 | } | 339 | } |
340 | |||
333 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 341 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
334 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 342 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
335 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 343 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
@@ -441,14 +449,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
441 | return sensedEntities; | 449 | return sensedEntities; |
442 | 450 | ||
443 | SceneObjectPart SensePoint = ts.host; | 451 | SceneObjectPart SensePoint = ts.host; |
444 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 452 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
445 | 453 | ||
446 | Quaternion q = SensePoint.RotationOffset; | 454 | Quaternion q = SensePoint.GetWorldRotation(); |
447 | if (SensePoint.ParentGroup.IsAttachment) | 455 | if (SensePoint.ParentGroup.IsAttachment) |
448 | { | 456 | { |
449 | // In attachments, the sensor cone always orients with the | 457 | // In attachments, rotate the sensor cone with the |
450 | // avatar rotation. This may include a nonzero elevation if | 458 | // avatar rotation. This may include a nonzero elevation if |
451 | // in mouselook. | 459 | // in mouselook. |
460 | // This will not include the rotation and position of the | ||
461 | // attachment point (e.g. your head when a sensor is in your | ||
462 | // hair attached to your scull. Your hair will turn with | ||
463 | // your head but the sensor will stay with your (global) | ||
464 | // avatar rotation and position. | ||
465 | // Position of a sensor in a child prim attached to an avatar | ||
466 | // will be still wrong. | ||
452 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 467 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
453 | if (avatar == null) | 468 | if (avatar == null) |
454 | return sensedEntities; | 469 | return sensedEntities; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 5c528977..eab6851 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -149,7 +149,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
149 | LSL_Rotation llGetLocalRot(); | 149 | LSL_Rotation llGetLocalRot(); |
150 | LSL_Float llGetMass(); | 150 | LSL_Float llGetMass(); |
151 | LSL_Float llGetMassMKS(); | 151 | LSL_Float llGetMassMKS(); |
152 | void llGetNextEmail(string address, string subject); | 152 | LSL_Integer llGetMemoryLimit(); |
153 | void llGetNextEmail(string address, string subject); | ||
153 | LSL_String llGetNotecardLine(string name, int line); | 154 | LSL_String llGetNotecardLine(string name, int line); |
154 | LSL_Key llGetNumberOfNotecardLines(string name); | 155 | LSL_Key llGetNumberOfNotecardLines(string name); |
155 | LSL_Integer llGetNumberOfPrims(); | 156 | LSL_Integer llGetNumberOfPrims(); |
@@ -187,6 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
187 | LSL_String llGetScriptName(); | 188 | LSL_String llGetScriptName(); |
188 | LSL_Integer llGetScriptState(string name); | 189 | LSL_Integer llGetScriptState(string name); |
189 | LSL_String llGetSimulatorHostname(); | 190 | LSL_String llGetSimulatorHostname(); |
191 | LSL_Integer llGetSPMaxMemory(); | ||
190 | LSL_Integer llGetStartParameter(); | 192 | LSL_Integer llGetStartParameter(); |
191 | LSL_Integer llGetStatus(int status); | 193 | LSL_Integer llGetStatus(int status); |
192 | LSL_String llGetSubString(string src, int start, int end); | 194 | LSL_String llGetSubString(string src, int start, int end); |
@@ -322,6 +324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
322 | void llSay(int channelID, string text); | 324 | void llSay(int channelID, string text); |
323 | void llScaleTexture(double u, double v, int face); | 325 | void llScaleTexture(double u, double v, int face); |
324 | LSL_Integer llScriptDanger(LSL_Vector pos); | 326 | LSL_Integer llScriptDanger(LSL_Vector pos); |
327 | void llScriptProfiler(LSL_Integer flag); | ||
325 | LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); | 328 | LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); |
326 | void llSensor(string name, string id, int type, double range, double arc); | 329 | void llSensor(string name, string id, int type, double range, double arc); |
327 | void llSensorRemove(); | 330 | void llSensorRemove(); |
@@ -345,6 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
345 | void llSetLinkTexture(int linknumber, string texture, int face); | 348 | void llSetLinkTexture(int linknumber, string texture, int face); |
346 | void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); | 349 | void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); |
347 | void llSetLocalRot(LSL_Rotation rot); | 350 | void llSetLocalRot(LSL_Rotation rot); |
351 | LSL_Integer llSetMemoryLimit(LSL_Integer limit); | ||
348 | void llSetObjectDesc(string desc); | 352 | void llSetObjectDesc(string desc); |
349 | void llSetObjectName(string name); | 353 | void llSetObjectName(string name); |
350 | void llSetObjectPermMask(int mask, int value); | 354 | void llSetObjectPermMask(int mask, int value); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 444a681..7382495 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
98 | void osAvatarPlayAnimation(string avatar, string animation); | 98 | void osAvatarPlayAnimation(string avatar, string animation); |
99 | void osAvatarStopAnimation(string avatar, string animation); | 99 | void osAvatarStopAnimation(string avatar, string animation); |
100 | 100 | ||
101 | // Attachment commands | ||
102 | |||
103 | /// <summary> | ||
104 | /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH | ||
105 | /// </summary> | ||
106 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | ||
107 | void osForceAttachToAvatar(int attachment); | ||
108 | |||
109 | /// <summary> | ||
110 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH | ||
111 | /// </summary> | ||
112 | /// <remarks>Nothing happens if the object is not attached.</remarks> | ||
113 | void osForceDetachFromAvatar(); | ||
114 | |||
101 | //texture draw functions | 115 | //texture draw functions |
102 | string osMovePen(string drawList, int x, int y); | 116 | string osMovePen(string drawList, int x, int y); |
103 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); | 117 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); |
@@ -203,11 +217,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
203 | void osNpcSetRot(LSL_Key npc, rotation rot); | 217 | void osNpcSetRot(LSL_Key npc, rotation rot); |
204 | void osNpcStopMoveToTarget(LSL_Key npc); | 218 | void osNpcStopMoveToTarget(LSL_Key npc); |
205 | void osNpcSay(key npc, string message); | 219 | void osNpcSay(key npc, string message); |
220 | void osNpcSay(key npc, int channel, string message); | ||
221 | void osNpcShout(key npc, int channel, string message); | ||
206 | void osNpcSit(key npc, key target, int options); | 222 | void osNpcSit(key npc, key target, int options); |
207 | void osNpcStand(LSL_Key npc); | 223 | void osNpcStand(LSL_Key npc); |
208 | void osNpcRemove(key npc); | 224 | void osNpcRemove(key npc); |
209 | void osNpcPlayAnimation(LSL_Key npc, string animation); | 225 | void osNpcPlayAnimation(LSL_Key npc, string animation); |
210 | void osNpcStopAnimation(LSL_Key npc, string animation); | 226 | void osNpcStopAnimation(LSL_Key npc, string animation); |
227 | void osNpcWhisper(key npc, int channel, string message); | ||
211 | 228 | ||
212 | LSL_Key osOwnerSaveAppearance(string notecard); | 229 | LSL_Key osOwnerSaveAppearance(string notecard); |
213 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); | 230 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); |
@@ -234,5 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
234 | 251 | ||
235 | LSL_Integer osInviteToGroup(LSL_Key agentId); | 252 | LSL_Integer osInviteToGroup(LSL_Key agentId); |
236 | LSL_Integer osEjectFromGroup(LSL_Key agentId); | 253 | LSL_Integer osEjectFromGroup(LSL_Key agentId); |
254 | |||
255 | void osSetTerrainTexture(int level, LSL_Key texture); | ||
256 | void osSetTerrainTextureHeight(int corner, double low, double high); | ||
237 | } | 257 | } |
238 | } | 258 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 6246b57..23b4336 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -383,6 +383,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
383 | public const int PRIM_SCULPT_FLAG_INVERT = 64; | 383 | public const int PRIM_SCULPT_FLAG_INVERT = 64; |
384 | public const int PRIM_SCULPT_FLAG_MIRROR = 128; | 384 | public const int PRIM_SCULPT_FLAG_MIRROR = 128; |
385 | 385 | ||
386 | public const int PROFILE_NONE = 0; | ||
387 | public const int PROFILE_SCRIPT_MEMORY = 1; | ||
388 | |||
386 | public const int MASK_BASE = 0; | 389 | public const int MASK_BASE = 0; |
387 | public const int MASK_OWNER = 1; | 390 | public const int MASK_OWNER = 1; |
388 | public const int MASK_GROUP = 2; | 391 | public const int MASK_GROUP = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 70c5fcd..9446099 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -586,6 +586,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
586 | return m_LSL_Functions.llGetMassMKS(); | 586 | return m_LSL_Functions.llGetMassMKS(); |
587 | } | 587 | } |
588 | 588 | ||
589 | public LSL_Integer llGetMemoryLimit() | ||
590 | { | ||
591 | return m_LSL_Functions.llGetMemoryLimit(); | ||
592 | } | ||
593 | |||
589 | public void llGetNextEmail(string address, string subject) | 594 | public void llGetNextEmail(string address, string subject) |
590 | { | 595 | { |
591 | m_LSL_Functions.llGetNextEmail(address, subject); | 596 | m_LSL_Functions.llGetNextEmail(address, subject); |
@@ -776,6 +781,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
776 | return m_LSL_Functions.llGetSimulatorHostname(); | 781 | return m_LSL_Functions.llGetSimulatorHostname(); |
777 | } | 782 | } |
778 | 783 | ||
784 | public LSL_Integer llGetSPMaxMemory() | ||
785 | { | ||
786 | return m_LSL_Functions.llGetSPMaxMemory(); | ||
787 | } | ||
788 | |||
779 | public LSL_Integer llGetStartParameter() | 789 | public LSL_Integer llGetStartParameter() |
780 | { | 790 | { |
781 | return m_LSL_Functions.llGetStartParameter(); | 791 | return m_LSL_Functions.llGetStartParameter(); |
@@ -1445,6 +1455,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1445 | return m_LSL_Functions.llScriptDanger(pos); | 1455 | return m_LSL_Functions.llScriptDanger(pos); |
1446 | } | 1456 | } |
1447 | 1457 | ||
1458 | public void llScriptProfiler(LSL_Integer flags) | ||
1459 | { | ||
1460 | m_LSL_Functions.llScriptProfiler(flags); | ||
1461 | } | ||
1462 | |||
1448 | public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) | 1463 | public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) |
1449 | { | 1464 | { |
1450 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); | 1465 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); |
@@ -1555,6 +1570,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1555 | m_LSL_Functions.llSetLocalRot(rot); | 1570 | m_LSL_Functions.llSetLocalRot(rot); |
1556 | } | 1571 | } |
1557 | 1572 | ||
1573 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) | ||
1574 | { | ||
1575 | return m_LSL_Functions.llSetMemoryLimit(limit); | ||
1576 | } | ||
1577 | |||
1558 | public void llSetObjectDesc(string desc) | 1578 | public void llSetObjectDesc(string desc) |
1559 | { | 1579 | { |
1560 | m_LSL_Functions.llSetObjectDesc(desc); | 1580 | m_LSL_Functions.llSetObjectDesc(desc); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 680cefb4..d230662 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); | 289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); |
290 | } | 290 | } |
291 | 291 | ||
292 | // Avatar functions | ||
292 | 293 | ||
293 | //Texture Draw functions | 294 | public void osForceAttachToAvatar(int attachmentPoint) |
295 | { | ||
296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); | ||
297 | } | ||
298 | |||
299 | public void osForceDetachFromAvatar() | ||
300 | { | ||
301 | m_OSSL_Functions.osForceDetachFromAvatar(); | ||
302 | } | ||
303 | |||
304 | // Texture Draw functions | ||
294 | 305 | ||
295 | public string osMovePen(string drawList, int x, int y) | 306 | public string osMovePen(string drawList, int x, int y) |
296 | { | 307 | { |
@@ -569,6 +580,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
569 | m_OSSL_Functions.osNpcSay(npc, message); | 580 | m_OSSL_Functions.osNpcSay(npc, message); |
570 | } | 581 | } |
571 | 582 | ||
583 | public void osNpcSay(key npc, int channel, string message) | ||
584 | { | ||
585 | m_OSSL_Functions.osNpcSay(npc, channel, message); | ||
586 | } | ||
587 | |||
588 | |||
589 | public void osNpcShout(key npc, int channel, string message) | ||
590 | { | ||
591 | m_OSSL_Functions.osNpcShout(npc, channel, message); | ||
592 | } | ||
593 | |||
572 | public void osNpcSit(LSL_Key npc, LSL_Key target, int options) | 594 | public void osNpcSit(LSL_Key npc, LSL_Key target, int options) |
573 | { | 595 | { |
574 | m_OSSL_Functions.osNpcSit(npc, target, options); | 596 | m_OSSL_Functions.osNpcSit(npc, target, options); |
@@ -594,6 +616,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
594 | m_OSSL_Functions.osNpcStopAnimation(npc, animation); | 616 | m_OSSL_Functions.osNpcStopAnimation(npc, animation); |
595 | } | 617 | } |
596 | 618 | ||
619 | public void osNpcWhisper(key npc, int channel, string message) | ||
620 | { | ||
621 | m_OSSL_Functions.osNpcWhisper(npc, channel, message); | ||
622 | } | ||
623 | |||
597 | public LSL_Key osOwnerSaveAppearance(string notecard) | 624 | public LSL_Key osOwnerSaveAppearance(string notecard) |
598 | { | 625 | { |
599 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); | 626 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); |
@@ -878,5 +905,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
878 | { | 905 | { |
879 | return m_OSSL_Functions.osEjectFromGroup(agentId); | 906 | return m_OSSL_Functions.osEjectFromGroup(agentId); |
880 | } | 907 | } |
908 | |||
909 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
910 | { | ||
911 | m_OSSL_Functions.osSetTerrainTexture(level, texture); | ||
912 | } | ||
913 | |||
914 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
915 | { | ||
916 | m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high); | ||
917 | } | ||
881 | } | 918 | } |
882 | } | 919 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ff1f277..0f763f1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
964 | public IScriptApi GetApi(string name) | 964 | public IScriptApi GetApi(string name) |
965 | { | 965 | { |
966 | if (m_Apis.ContainsKey(name)) | 966 | if (m_Apis.ContainsKey(name)) |
967 | { | ||
968 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
969 | |||
967 | return m_Apis[name]; | 970 | return m_Apis[name]; |
971 | } | ||
972 | |||
973 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
974 | |||
968 | return null; | 975 | return null; |
969 | } | 976 | } |
970 | 977 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index e2d0db2..49266e9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
63 | IConfig config = initConfigSource.AddConfig("XEngine"); | 63 | IConfig config = initConfigSource.AddConfig("XEngine"); |
64 | config.Set("Enabled", "true"); | 64 | config.Set("Enabled", "true"); |
65 | 65 | ||
66 | m_scene = SceneHelpers.SetupScene(); | 66 | m_scene = new SceneHelpers().SetupScene(); |
67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | 67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); |
68 | 68 | ||
69 | m_engine = new XEngine.XEngine(); | 69 | m_engine = new XEngine.XEngine(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 9cf9258..92a63bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
58 | IConfig config = initConfigSource.AddConfig("XEngine"); | 58 | IConfig config = initConfigSource.AddConfig("XEngine"); |
59 | config.Set("Enabled", "true"); | 59 | config.Set("Enabled", "true"); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
63 | 63 | ||
64 | XEngine.XEngine engine = new XEngine.XEngine(); | 64 | XEngine.XEngine engine = new XEngine.XEngine(); |
@@ -261,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
261 | TestHelpers.InMethod(); | 261 | TestHelpers.InMethod(); |
262 | 262 | ||
263 | // Create Prim1. | 263 | // Create Prim1. |
264 | Scene scene = SceneHelpers.SetupScene(); | 264 | Scene scene = new SceneHelpers().SetupScene(); |
265 | string obj1Name = "Prim1"; | 265 | string obj1Name = "Prim1"; |
266 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 266 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
267 | SceneObjectPart part1 = | 267 | SceneObjectPart part1 = |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 7573dff..c51227b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
67 | config = initConfigSource.AddConfig("NPC"); | 67 | config = initConfigSource.AddConfig("NPC"); |
68 | config.Set("Enabled", "true"); | 68 | config.Set("Enabled", "true"); |
69 | 69 | ||
70 | m_scene = SceneHelpers.SetupScene(); | 70 | m_scene = new SceneHelpers().SetupScene(); |
71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
72 | 72 | ||
73 | m_engine = new XEngine.XEngine(); | 73 | m_engine = new XEngine.XEngine(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 9d9fc51..9c36108 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
68 | config = initConfigSource.AddConfig("NPC"); | 68 | config = initConfigSource.AddConfig("NPC"); |
69 | config.Set("Enabled", "true"); | 69 | config.Set("Enabled", "true"); |
70 | 70 | ||
71 | m_scene = SceneHelpers.SetupScene(); | 71 | m_scene = new SceneHelpers().SetupScene(); |
72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
73 | 73 | ||
74 | m_engine = new XEngine.XEngine(); | 74 | m_engine = new XEngine.XEngine(); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index 7d7bd82..a3f848c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
73 | // to AssemblyResolver.OnAssemblyResolve fails. | 73 | // to AssemblyResolver.OnAssemblyResolve fails. |
74 | xEngineConfig.Set("AppDomainLoading", "false"); | 74 | xEngineConfig.Set("AppDomainLoading", "false"); |
75 | 75 | ||
76 | m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource); | 76 | m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); |
77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); | 77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); |
78 | m_scene.StartScripts(); | 78 | m_scene.StartScripts(); |
79 | } | 79 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 1e0f01f..eeb125e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1089,11 +1089,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1089 | 1089 | ||
1090 | AppDomain sandbox; | 1090 | AppDomain sandbox; |
1091 | if (m_AppDomainLoading) | 1091 | if (m_AppDomainLoading) |
1092 | { | ||
1092 | sandbox = AppDomain.CreateDomain( | 1093 | sandbox = AppDomain.CreateDomain( |
1093 | m_Scene.RegionInfo.RegionID.ToString(), | 1094 | m_Scene.RegionInfo.RegionID.ToString(), |
1094 | evidence, appSetup); | 1095 | evidence, appSetup); |
1096 | m_AppDomains[appDomain].AssemblyResolve += | ||
1097 | new ResolveEventHandler( | ||
1098 | AssemblyResolver.OnAssemblyResolve); | ||
1099 | } | ||
1095 | else | 1100 | else |
1101 | { | ||
1096 | sandbox = AppDomain.CurrentDomain; | 1102 | sandbox = AppDomain.CurrentDomain; |
1103 | } | ||
1097 | 1104 | ||
1098 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 1105 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
1099 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 1106 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); |
@@ -1105,9 +1112,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1105 | 1112 | ||
1106 | m_AppDomains[appDomain] = sandbox; | 1113 | m_AppDomains[appDomain] = sandbox; |
1107 | 1114 | ||
1108 | m_AppDomains[appDomain].AssemblyResolve += | ||
1109 | new ResolveEventHandler( | ||
1110 | AssemblyResolver.OnAssemblyResolve); | ||
1111 | m_DomainScripts[appDomain] = new List<UUID>(); | 1115 | m_DomainScripts[appDomain] = new List<UUID>(); |
1112 | } | 1116 | } |
1113 | catch (Exception e) | 1117 | catch (Exception e) |
@@ -1898,9 +1902,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1898 | // if there already exists a file at that location, it may be locked. | 1902 | // if there already exists a file at that location, it may be locked. |
1899 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | 1903 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); |
1900 | } | 1904 | } |
1905 | |||
1906 | string textpath = path + ".text"; | ||
1901 | try | 1907 | try |
1902 | { | 1908 | { |
1903 | using (FileStream fs = File.Create(path + ".text")) | 1909 | using (FileStream fs = File.Create(textpath)) |
1904 | { | 1910 | { |
1905 | using (StreamWriter sw = new StreamWriter(fs)) | 1911 | using (StreamWriter sw = new StreamWriter(fs)) |
1906 | { | 1912 | { |
@@ -1913,7 +1919,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1913 | catch (IOException ex) | 1919 | catch (IOException ex) |
1914 | { | 1920 | { |
1915 | // if there already exists a file at that location, it may be locked. | 1921 | // if there already exists a file at that location, it may be locked. |
1916 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | 1922 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", textpath, ex.Message); |
1917 | } | 1923 | } |
1918 | } | 1924 | } |
1919 | } | 1925 | } |
@@ -1962,7 +1968,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1962 | catch (IOException ex) | 1968 | catch (IOException ex) |
1963 | { | 1969 | { |
1964 | // if there already exists a file at that location, it may be locked. | 1970 | // if there already exists a file at that location, it may be locked. |
1965 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | 1971 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", mappath, ex.Message); |
1966 | } | 1972 | } |
1967 | } | 1973 | } |
1968 | 1974 | ||
@@ -1997,45 +2003,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1997 | if (!topScripts.ContainsKey(si.LocalID)) | 2003 | if (!topScripts.ContainsKey(si.LocalID)) |
1998 | topScripts[si.RootLocalID] = 0; | 2004 | topScripts[si.RootLocalID] = 0; |
1999 | 2005 | ||
2000 | // long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | 2006 | topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow); |
2001 | // float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); | 2007 | } |
2002 | 2008 | } | |
2003 | // Execution time of the script adjusted by it's measurement period to make scripts started at | ||
2004 | // different times comparable. | ||
2005 | // float adjustedExecutionTime | ||
2006 | // = (float)si.MeasurementPeriodExecutionTime | ||
2007 | // / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod) | ||
2008 | // / TimeSpan.TicksPerMillisecond; | ||
2009 | |||
2010 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
2011 | |||
2012 | // Avoid divide by zerp | ||
2013 | if (ticksElapsed == 0) | ||
2014 | ticksElapsed = 1; | ||
2015 | 2009 | ||
2016 | // Scale execution time to the ideal 55 fps frame time for these reasons. | 2010 | return topScripts; |
2017 | // | 2011 | } |
2018 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
2019 | // 'script execution time per frame', which is the original purpose of this value. | ||
2020 | // | ||
2021 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
2022 | // it impossible to compare scripts. | ||
2023 | // | ||
2024 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
2025 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
2026 | // for much longer. | ||
2027 | // | ||
2028 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
2029 | // since the figure does not represent actual execution time and very hard running scripts will | ||
2030 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
2031 | float adjustedExecutionTime | ||
2032 | = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
2033 | 2012 | ||
2034 | topScripts[si.RootLocalID] += adjustedExecutionTime; | 2013 | public float GetScriptExecutionTime(List<UUID> itemIDs) |
2014 | { | ||
2015 | if (itemIDs == null|| itemIDs.Count == 0) | ||
2016 | { | ||
2017 | return 0.0f; | ||
2018 | } | ||
2019 | float time = 0.0f; | ||
2020 | long tickNow = Util.EnvironmentTickCount(); | ||
2021 | IScriptInstance si; | ||
2022 | // Calculate the time for all scripts that this engine is executing | ||
2023 | // Ignore any others | ||
2024 | foreach (UUID id in itemIDs) | ||
2025 | { | ||
2026 | si = GetInstance(id); | ||
2027 | if (si != null && si.Running) | ||
2028 | { | ||
2029 | time += CalculateAdjustedExectionTime(si, tickNow); | ||
2035 | } | 2030 | } |
2036 | } | 2031 | } |
2032 | return time; | ||
2033 | } | ||
2037 | 2034 | ||
2038 | return topScripts; | 2035 | private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow) |
2036 | { | ||
2037 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
2038 | |||
2039 | // Avoid divide by zero | ||
2040 | if (ticksElapsed == 0) | ||
2041 | ticksElapsed = 1; | ||
2042 | |||
2043 | // Scale execution time to the ideal 55 fps frame time for these reasons. | ||
2044 | // | ||
2045 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
2046 | // 'script execution time per frame', which is the original purpose of this value. | ||
2047 | // | ||
2048 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
2049 | // it impossible to compare scripts. | ||
2050 | // | ||
2051 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
2052 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
2053 | // for much longer. | ||
2054 | // | ||
2055 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
2056 | // since the figure does not represent actual execution time and very hard running scripts will | ||
2057 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
2058 | return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
2039 | } | 2059 | } |
2040 | 2060 | ||
2041 | public void SuspendScript(UUID itemID) | 2061 | public void SuspendScript(UUID itemID) |