shuffling code around so that the interface for ISoundModule.SendSound() specifies a UUID rather than a string

integration
SignpostMarv 2012-10-16 12:40:21 +01:00 committed by Justin Clark-Casey (justincc)
parent 5abcecc735
commit c5af16aef8
5 changed files with 47 additions and 28 deletions

View File

@ -278,10 +278,13 @@ namespace OpenSim.Region.CoreModules.World.Sound
m_host.SendFullUpdateToAllClients(); 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 triggered, byte flags, float radius, bool useMaster,
bool isMaster) bool isMaster)
{ {
if (soundID == UUID.Zero)
return;
SceneObjectPart part; SceneObjectPart part;
if (!m_scene.TryGetSceneObjectPart(objectID, out part)) if (!m_scene.TryGetSceneObjectPart(objectID, out part))
return; return;
@ -290,29 +293,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
UUID parentID = part.ParentGroup.UUID; UUID parentID = part.ParentGroup.UUID;
UUID soundID = UUID.Zero;
Vector3 position = part.AbsolutePosition; // region local Vector3 position = part.AbsolutePosition; // region local
ulong regionHandle = m_scene.RegionInfo.RegionHandle; ulong regionHandle = m_scene.RegionInfo.RegionHandle;
if (!UUID.TryParse(sound, out soundID))
{
// search sound file from inventory
lock (part.TaskInventory)
{
foreach (KeyValuePair<UUID, TaskInventoryItem> 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 (useMaster)
{ {
if (isMaster) if (isMaster)

View File

@ -108,7 +108,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="radius"></param> /// <param name="radius"></param>
/// <param name="useMaster"></param> /// <param name="useMaster"></param>
/// <param name="isMaster"></param> /// <param name="isMaster"></param>
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 triggered, byte flags, float radius, bool useMaster,
bool isMaster); bool isMaster);
} }

View File

@ -2243,7 +2243,7 @@ namespace OpenSim.Region.Framework.Scenes
ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
if (soundModule != null) if (soundModule != null)
{ {
soundModule.SendSound(UUID, CollisionSound.ToString(), soundModule.SendSound(UUID, CollisionSound,
CollisionSoundVolume, true, (byte)0, 0, false, CollisionSoundVolume, true, (byte)0, 0, false,
false); false);
} }

View File

@ -824,7 +824,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
ISoundModule module = m_rootScene.RequestModuleInterface<ISoundModule>(); ISoundModule module = m_rootScene.RequestModuleInterface<ISoundModule>();
if (module != null) 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);
} }
} }

View File

@ -333,6 +333,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return key; return key;
} }
/// <summary>
/// Return the UUID of the asset matching the specified key or name
/// and asset type.
/// </summary>
/// <param name="k"></param>
/// <param name="type"></param>
/// <returns></returns>
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<UUID, TaskInventoryItem> 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. //These are the implementations of the various ll-functions used by the LSL scripts.
public LSL_Float llSin(double f) 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 // send the sound, once, to all clients in range
if (m_SoundModule != null) 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 // send the sound, once, to all clients in range
if (m_SoundModule != null) 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. // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory.
if (m_SoundModule != null) 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 radius1 = (float)llVecDist(llGetPos(), top_north_east);
float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); float radius2 = (float)llVecDist(llGetPos(), bottom_south_west);
float radius = Math.Abs(radius1 - radius2); 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);
} }
} }