transposing preload sound onto sound module

integration
SignpostMarv 2012-10-05 15:16:30 +01:00 committed by Justin Clark-Casey (justincc)
parent 8763a637b5
commit a68e2fe169
4 changed files with 32 additions and 32 deletions

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
@ -223,6 +224,25 @@ namespace OpenSim.Region.CoreModules.World.Sound
}
}
public virtual void PreloadSound(UUID soundID, UUID objectID, float radius)
{
SceneObjectPart part;
if (soundID == UUID.Zero
|| !m_scene.TryGetSceneObjectPart(objectID, out part))
{
return;
}
if (radius == 0)
radius = MaxDistance;
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{
if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance))
sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
});
}
#endregion
}
}

View File

@ -74,5 +74,15 @@ namespace OpenSim.Region.Framework.Interfaces
/// </summary>
/// <param name="objectID">Sound source ID</param>
void StopSound(UUID objectID);
/// <summary>
/// Preload sound to viewers within range.
/// </summary>
/// <param name="soundID">Sound asset ID</param>
/// <param name="objectID">Sound source ID</param>
/// <param name="radius">
/// Radius used to determine which viewers should preload the sound.
/// </param>
void PreloadSound(UUID soundID, UUID objectID, float radius);
}
}

View File

@ -2287,37 +2287,6 @@ namespace OpenSim.Region.Framework.Scenes
ScheduleTerseUpdate();
}
public void PreloadSound(string sound)
{
// UUID ownerID = OwnerID;
UUID objectID = ParentGroup.RootPart.UUID;
UUID soundID = UUID.Zero;
if (!UUID.TryParse(sound, out soundID))
{
//Trys to fetch sound id from prim's inventory.
//Prim's inventory doesn't support non script items yet
lock (TaskInventory)
{
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
{
if (item.Value.Name == sound)
{
soundID = item.Value.ItemID;
break;
}
}
}
}
ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{
if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100))
sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
});
}
public void RemFlag(PrimFlags flag)
{
// PrimFlags prevflag = Flags;

View File

@ -2461,7 +2461,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llPreloadSound(string sound)
{
m_host.AddScriptLPS(1);
m_host.PreloadSound(sound);
if (m_SoundModule != null)
m_SoundModule.PreloadSound(KeyOrName(sound), m_host.UUID, 0);
ScriptSleep(1000);
}