diff options
author | Melanie | 2013-02-06 02:22:12 +0000 |
---|---|---|
committer | Melanie | 2013-02-06 02:22:12 +0000 |
commit | f567ff9f51aebe522c210b5d34b26754de157c91 (patch) | |
tree | eac712a0ba78ca92b3178e2d532307c4ed489b06 /OpenSim/Region/ScriptEngine | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Remove unused ScriptEngineLoader and ScriptEngineInterface in OpenSim.Region.... (diff) | |
download | opensim-SC_OLD-f567ff9f51aebe522c210b5d34b26754de157c91.zip opensim-SC_OLD-f567ff9f51aebe522c210b5d34b26754de157c91.tar.gz opensim-SC_OLD-f567ff9f51aebe522c210b5d34b26754de157c91.tar.bz2 opensim-SC_OLD-f567ff9f51aebe522c210b5d34b26754de157c91.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 104 |
1 files changed, 15 insertions, 89 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f4a812c..8be39a7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
48 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Scenes.Serialization; | 49 | using OpenSim.Region.Framework.Scenes.Serialization; |
50 | using OpenSim.Region.Framework.Scenes.Animation; | 50 | using OpenSim.Region.Framework.Scenes.Animation; |
51 | using OpenSim.Region.Framework.Scenes.Scripting; | ||
51 | using OpenSim.Region.Physics.Manager; | 52 | using OpenSim.Region.Physics.Manager; |
52 | using OpenSim.Region.ScriptEngine.Shared; | 53 | using OpenSim.Region.ScriptEngine.Shared; |
53 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 54 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
@@ -423,79 +424,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
423 | } | 424 | } |
424 | } | 425 | } |
425 | 426 | ||
426 | protected UUID InventoryKey(string name, int type) | ||
427 | { | ||
428 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); | ||
429 | |||
430 | if (item != null && item.Type == type) | ||
431 | return item.AssetID; | ||
432 | else | ||
433 | return UUID.Zero; | ||
434 | } | ||
435 | |||
436 | /// <summary> | ||
437 | /// accepts a valid UUID, -or- a name of an inventory item. | ||
438 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found | ||
439 | /// in prim inventory. | ||
440 | /// </summary> | ||
441 | /// <param name="k"></param> | ||
442 | /// <returns></returns> | ||
443 | protected UUID KeyOrName(string k) | ||
444 | { | ||
445 | UUID key; | ||
446 | |||
447 | // if we can parse the string as a key, use it. | ||
448 | // else try to locate the name in inventory of object. found returns key, | ||
449 | // not found returns UUID.Zero | ||
450 | if (!UUID.TryParse(k, out key)) | ||
451 | { | ||
452 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); | ||
453 | |||
454 | if (item != null) | ||
455 | key = item.AssetID; | ||
456 | else | ||
457 | key = UUID.Zero; | ||
458 | } | ||
459 | |||
460 | return key; | ||
461 | } | ||
462 | |||
463 | /// <summary> | ||
464 | /// Return the UUID of the asset matching the specified key or name | ||
465 | /// and asset type. | ||
466 | /// </summary> | ||
467 | /// <param name="k"></param> | ||
468 | /// <param name="type"></param> | ||
469 | /// <returns></returns> | ||
470 | protected UUID KeyOrName(string k, AssetType type) | ||
471 | { | ||
472 | UUID key; | ||
473 | |||
474 | if (!UUID.TryParse(k, out key)) | ||
475 | { | ||
476 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); | ||
477 | if (item != null && item.Type == (int)type) | ||
478 | key = item.AssetID; | ||
479 | } | ||
480 | else | ||
481 | { | ||
482 | lock (m_host.TaskInventory) | ||
483 | { | ||
484 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in m_host.TaskInventory) | ||
485 | { | ||
486 | if (item.Value.Type == (int)type && item.Value.Name == k) | ||
487 | { | ||
488 | key = item.Value.ItemID; | ||
489 | break; | ||
490 | } | ||
491 | } | ||
492 | } | ||
493 | } | ||
494 | |||
495 | |||
496 | return key; | ||
497 | } | ||
498 | |||
499 | //These are the implementations of the various ll-functions used by the LSL scripts. | 427 | //These are the implementations of the various ll-functions used by the LSL scripts. |
500 | public LSL_Float llSin(double f) | 428 | public LSL_Float llSin(double f) |
501 | { | 429 | { |
@@ -2035,7 +1963,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2035 | 1963 | ||
2036 | UUID textureID = new UUID(); | 1964 | UUID textureID = new UUID(); |
2037 | 1965 | ||
2038 | textureID = InventoryKey(texture, (int)AssetType.Texture); | 1966 | textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); |
2039 | if (textureID == UUID.Zero) | 1967 | if (textureID == UUID.Zero) |
2040 | { | 1968 | { |
2041 | if (!UUID.TryParse(texture, out textureID)) | 1969 | if (!UUID.TryParse(texture, out textureID)) |
@@ -2751,7 +2679,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2751 | if (m_SoundModule != null) | 2679 | if (m_SoundModule != null) |
2752 | { | 2680 | { |
2753 | m_SoundModule.SendSound(m_host.UUID, | 2681 | m_SoundModule.SendSound(m_host.UUID, |
2754 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | 2682 | ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0, |
2755 | 0, false, false); | 2683 | 0, false, false); |
2756 | } | 2684 | } |
2757 | } | 2685 | } |
@@ -2761,7 +2689,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2761 | m_host.AddScriptLPS(1); | 2689 | m_host.AddScriptLPS(1); |
2762 | if (m_SoundModule != null) | 2690 | if (m_SoundModule != null) |
2763 | { | 2691 | { |
2764 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), | 2692 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), |
2765 | volume, 20, false); | 2693 | volume, 20, false); |
2766 | } | 2694 | } |
2767 | } | 2695 | } |
@@ -2771,7 +2699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2771 | m_host.AddScriptLPS(1); | 2699 | m_host.AddScriptLPS(1); |
2772 | if (m_SoundModule != null) | 2700 | if (m_SoundModule != null) |
2773 | { | 2701 | { |
2774 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), | 2702 | m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), |
2775 | volume, 20, true); | 2703 | volume, 20, true); |
2776 | } | 2704 | } |
2777 | } | 2705 | } |
@@ -2793,7 +2721,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2793 | if (m_SoundModule != null) | 2721 | if (m_SoundModule != null) |
2794 | { | 2722 | { |
2795 | m_SoundModule.SendSound(m_host.UUID, | 2723 | m_SoundModule.SendSound(m_host.UUID, |
2796 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | 2724 | ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0, |
2797 | 0, true, false); | 2725 | 0, true, false); |
2798 | } | 2726 | } |
2799 | } | 2727 | } |
@@ -2805,7 +2733,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2805 | if (m_SoundModule != null) | 2733 | if (m_SoundModule != null) |
2806 | { | 2734 | { |
2807 | m_SoundModule.SendSound(m_host.UUID, | 2735 | m_SoundModule.SendSound(m_host.UUID, |
2808 | KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, | 2736 | ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, true, 0, 0, |
2809 | false, false); | 2737 | false, false); |
2810 | } | 2738 | } |
2811 | } | 2739 | } |
@@ -2822,7 +2750,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2822 | { | 2750 | { |
2823 | m_host.AddScriptLPS(1); | 2751 | m_host.AddScriptLPS(1); |
2824 | if (m_SoundModule != null) | 2752 | if (m_SoundModule != null) |
2825 | m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0); | 2753 | m_SoundModule.PreloadSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 0); |
2826 | ScriptSleep(1000); | 2754 | ScriptSleep(1000); |
2827 | } | 2755 | } |
2828 | 2756 | ||
@@ -3699,7 +3627,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3699 | if (presence != null) | 3627 | if (presence != null) |
3700 | { | 3628 | { |
3701 | // Do NOT try to parse UUID, animations cannot be triggered by ID | 3629 | // Do NOT try to parse UUID, animations cannot be triggered by ID |
3702 | UUID animID = InventoryKey(anim, (int)AssetType.Animation); | 3630 | UUID animID = ScriptUtils.GetAssetIdFromItemName(m_host, anim, (int)AssetType.Animation); |
3703 | if (animID == UUID.Zero) | 3631 | if (animID == UUID.Zero) |
3704 | presence.Animator.AddAnimation(anim, m_host.UUID); | 3632 | presence.Animator.AddAnimation(anim, m_host.UUID); |
3705 | else | 3633 | else |
@@ -3721,7 +3649,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3721 | 3649 | ||
3722 | if (presence != null) | 3650 | if (presence != null) |
3723 | { | 3651 | { |
3724 | UUID animID = KeyOrName(anim); | 3652 | UUID animID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, anim); |
3725 | 3653 | ||
3726 | if (animID == UUID.Zero) | 3654 | if (animID == UUID.Zero) |
3727 | presence.Animator.RemoveAnimation(anim); | 3655 | presence.Animator.RemoveAnimation(anim); |
@@ -4717,7 +4645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4717 | 4645 | ||
4718 | private void DoLLTeleport(ScenePresence sp, string destination, Vector3 targetPos, Vector3 targetLookAt) | 4646 | private void DoLLTeleport(ScenePresence sp, string destination, Vector3 targetPos, Vector3 targetLookAt) |
4719 | { | 4647 | { |
4720 | UUID assetID = KeyOrName(destination); | 4648 | UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, destination); |
4721 | 4649 | ||
4722 | // The destinaion is not an asset ID and also doesn't name a landmark. | 4650 | // The destinaion is not an asset ID and also doesn't name a landmark. |
4723 | // Use it as a sim name | 4651 | // Use it as a sim name |
@@ -4791,7 +4719,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4791 | return; | 4719 | return; |
4792 | } | 4720 | } |
4793 | // TODO: Parameter check logic required. | 4721 | // TODO: Parameter check logic required. |
4794 | m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); | 4722 | m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound); |
4795 | m_host.CollisionSoundVolume = (float)impact_volume; | 4723 | m_host.CollisionSoundVolume = (float)impact_volume; |
4796 | m_host.CollisionSoundType = 1; | 4724 | m_host.CollisionSoundType = 1; |
4797 | } | 4725 | } |
@@ -6356,7 +6284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6356 | if (m_SoundModule != null) | 6284 | if (m_SoundModule != null) |
6357 | { | 6285 | { |
6358 | m_SoundModule.TriggerSoundLimited(m_host.UUID, | 6286 | m_SoundModule.TriggerSoundLimited(m_host.UUID, |
6359 | KeyOrName(sound, AssetType.Sound), volume, | 6287 | ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, |
6360 | bottom_south_west, top_north_east); | 6288 | bottom_south_west, top_north_east); |
6361 | } | 6289 | } |
6362 | } | 6290 | } |
@@ -6827,7 +6755,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6827 | break; | 6755 | break; |
6828 | 6756 | ||
6829 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: | 6757 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: |
6830 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); | 6758 | prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1)); |
6831 | break; | 6759 | break; |
6832 | 6760 | ||
6833 | case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: | 6761 | case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: |
@@ -7776,9 +7704,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7776 | UUID sculptId; | 7704 | UUID sculptId; |
7777 | 7705 | ||
7778 | if (!UUID.TryParse(map, out sculptId)) | 7706 | if (!UUID.TryParse(map, out sculptId)) |
7779 | { | 7707 | sculptId = ScriptUtils.GetAssetIdFromItemName(m_host, map, (int)AssetType.Texture); |
7780 | sculptId = InventoryKey(map, (int)AssetType.Texture); | ||
7781 | } | ||
7782 | 7708 | ||
7783 | if (sculptId == UUID.Zero) | 7709 | if (sculptId == UUID.Zero) |
7784 | return; | 7710 | return; |