diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 37863ee21d..417c071147 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -278,10 +278,13 @@ namespace OpenSim.Region.CoreModules.World.Sound m_host.SendFullUpdateToAllClients(); } - public void SendSound(UUID objectID, string sound, double volume, + public void SendSound(UUID objectID, UUID soundID, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster) { + if (soundID == UUID.Zero) + return; + SceneObjectPart part; if (!m_scene.TryGetSceneObjectPart(objectID, out part)) return; @@ -290,29 +293,9 @@ namespace OpenSim.Region.CoreModules.World.Sound UUID parentID = part.ParentGroup.UUID; - UUID soundID = UUID.Zero; Vector3 position = part.AbsolutePosition; // region local ulong regionHandle = m_scene.RegionInfo.RegionHandle; - if (!UUID.TryParse(sound, out soundID)) - { - // search sound file from inventory - lock (part.TaskInventory) - { - foreach (KeyValuePair item in part.TaskInventory) - { - if (item.Value.Type == (int)AssetType.Sound && item.Value.Name == sound) - { - soundID = item.Value.ItemID; - break; - } - } - } - } - - if (soundID == UUID.Zero) - return; - if (useMaster) { if (isMaster) diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index c5edcb0cc1..5d1bb63ec7 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -108,7 +108,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// - void SendSound(UUID objectID, string sound, double volume, + void SendSound(UUID objectID, UUID sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cbb92b2627..f79ac969c2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2243,7 +2243,7 @@ namespace OpenSim.Region.Framework.Scenes ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); if (soundModule != null) { - soundModule.SendSound(UUID, CollisionSound.ToString(), + soundModule.SendSound(UUID, CollisionSound, CollisionSoundVolume, true, (byte)0, 0, false, false); } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 9e438e232f..5ed1514ad4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -824,7 +824,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule ISoundModule module = m_rootScene.RequestModuleInterface(); if (module != null) { - module.SendSound(GetSOP().UUID, asset.ToString(), volume, true, 0, 0, false, false); + module.SendSound(GetSOP().UUID, asset, volume, true, 0, 0, false, false); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f29be92ea5..869d94efc9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -333,6 +333,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return key; } + /// + /// Return the UUID of the asset matching the specified key or name + /// and asset type. + /// + /// + /// + /// + protected UUID KeyOrName(string k, AssetType type) + { + UUID key; + + if (!UUID.TryParse(k, out key)) + { + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); + if (item != null && item.Type == (int)type) + key = item.AssetID; + } + else + { + lock (m_host.TaskInventory) + { + foreach (KeyValuePair item in m_host.TaskInventory) + { + if (item.Value.Type == (int)type && item.Value.Name == k) + { + key = item.Value.ItemID; + break; + } + } + } + } + + + return key; + } + //These are the implementations of the various ll-functions used by the LSL scripts. public LSL_Float llSin(double f) { @@ -2369,7 +2405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // send the sound, once, to all clients in range if (m_SoundModule != null) { - m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound, AssetType.Sound), volume, false, 0, 0, false, false); } } @@ -2409,7 +2445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // send the sound, once, to all clients in range if (m_SoundModule != null) { - m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, false, 0, 0, true, false); + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound, AssetType.Sound), volume, false, 0, 0, true, false); } } @@ -2419,7 +2455,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. if (m_SoundModule != null) { - m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, true, 0, 0, false, false); + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, false, false); } } @@ -5838,7 +5874,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api float radius1 = (float)llVecDist(llGetPos(), top_north_east); float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); float radius = Math.Abs(radius1 - radius2); - m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, true, 0, radius, false, false); + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound, AssetType.Sound), volume, true, 0, radius, false, false); } }