From fad6295398cf0c7bbcc08cfae1efae495bfde29b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 14 Nov 2018 19:02:00 +0000 Subject: [PATCH] change ossl link sound functions to search for sound both on script host and target prims --- .../Framework/Scenes/Scripting/ScriptUtils.cs | 28 +++++++++++--- .../Shared/Api/Implementation/OSSL_Api.cs | 38 ++++++++++--------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs index f08ba59ea3..94653d54d5 100644 --- a/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs +++ b/OpenSim/Region/Framework/Scenes/Scripting/ScriptUtils.cs @@ -93,15 +93,33 @@ namespace OpenSim.Region.Framework.Scenes.Scripting public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type) { UUID key; + if (UUID.TryParse(identifier, out key)) + return key; - if (!UUID.TryParse(identifier, out key)) + TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); + if (item != null && item.Type == (int)type) + return item.AssetID; + + return UUID.Zero; + } + + public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, SceneObjectPart host, string identifier, AssetType type) + { + UUID key; + if (UUID.TryParse(identifier, out key)) + return key; + + TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); + if (item != null && item.Type == (int)type) + return item.AssetID; + + if (part.LocalId != host.LocalId) { - TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); + item = host.Inventory.GetInventoryItem(identifier); if (item != null && item.Type == (int)type) - key = item.AssetID; + return item.AssetID; } - - return key; + return UUID.Zero; } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1e0d2e5a15..a032715214 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -4900,7 +4900,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; sop.AdjustSoundGain(volume); - ScriptSleep(100); } public void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius) @@ -4909,7 +4908,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectPart sop = GetSingleLinkPart(linknum); if(sop == null) return; - m_host.SoundRadius = radius; + sop.SoundRadius = radius; } public void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) @@ -4923,8 +4922,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; // send the sound, once, to all clients in range @@ -4942,8 +4941,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; m_SoundModule.LoopSound(sop.UUID, soundID, volume, false,false); @@ -4953,12 +4952,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + if (m_SoundModule == null) + return; + SceneObjectPart sop = GetSingleLinkPart(linknum); if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; m_SoundModule.LoopSound(sop.UUID, soundID, volume, true, false); @@ -4975,8 +4977,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; m_SoundModule.LoopSound(sop.UUID, soundID, volume, false, true); @@ -4993,8 +4995,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; // send the sound, once, to all clients in range @@ -5012,8 +5014,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. @@ -5032,8 +5034,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; m_SoundModule.TriggerSoundLimited(sop.UUID, soundID, volume, @@ -5065,8 +5067,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sop == null) return; - UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); - if(soundID == UUID.Zero) + UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound); + if (soundID == UUID.Zero) return; m_SoundModule.PreloadSound(sop.UUID, soundID);