Patch from mikkopa/_someone Thanks! adds support for llPreloadSound, llTriggerSound, llPlaySound, llPreloadSound.

* Time to make music boxes?
ThreadPoolClientBranch
Teravus Ovares 2008-02-04 14:40:46 +00:00
parent 5ffc225545
commit 3ff5ad1ed3
5 changed files with 114 additions and 6 deletions

View File

@ -605,6 +605,7 @@ namespace OpenSim.Framework
void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID); void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID);
void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags); void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags);
void SendTriggeredSound(LLUUID soundID, LLUUID ownerID, LLUUID objectID, LLUUID parentID, ulong handle, LLVector3 position, float gain);
void SendNameReply(LLUUID profileId, string firstname, string lastname); void SendNameReply(LLUUID profileId, string firstname, string lastname);
void SendAlertMessage(string message); void SendAlertMessage(string message);

View File

@ -1349,6 +1349,20 @@ namespace OpenSim.Region.ClientStack
OutPacket(sound, ThrottleOutPacketType.Task); OutPacket(sound, ThrottleOutPacketType.Task);
} }
public void SendTriggeredSound(LLUUID soundID, LLUUID ownerID, LLUUID objectID, LLUUID parentID, ulong handle, LLVector3 position, float gain)
{
SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
sound.SoundData.SoundID = soundID;
sound.SoundData.OwnerID = ownerID;
sound.SoundData.ObjectID = objectID;
sound.SoundData.ParentID = parentID;
sound.SoundData.Handle = handle;
sound.SoundData.Position = position;
sound.SoundData.Gain = gain;
OutPacket(sound, ThrottleOutPacketType.Task);
}
public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel)
{ {
SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage); SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);

View File

@ -392,6 +392,10 @@ namespace SimpleApp
{ {
} }
public void SendTriggeredSound(LLUUID soundID, LLUUID ownerID, LLUUID objectID, LLUUID parentID, ulong handle, LLVector3 position, float gain)
{
}
public void SendAlertMessage(string message) public void SendAlertMessage(string message)
{ {
} }

View File

@ -34,6 +34,7 @@ using System.Threading;
using Axiom.Math; using Axiom.Math;
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ScriptEngine.Common; using OpenSim.Region.ScriptEngine.Common;
@ -898,12 +899,44 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llSound() public void llSound()
{ {
// This function has been deprecated
// see http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSound
NotImplemented("llSound"); NotImplemented("llSound");
} }
public void llPlaySound(string sound, double volume) public void llPlaySound(string sound, double volume)
{ {
NotImplemented("llPlaySound"); if (volume > 1)
volume = 1;
if (volume < 0)
volume = 0;
LLUUID ownerID = m_host.OwnerID;
LLUUID objectID = m_host.UUID;
LLUUID soundID = LLUUID.Zero;
byte flags = 0;
if (!LLUUID.TryParse(sound, out soundID))
{
//Trys to fetch sound id from prim's inventory.
//Prim's inventory doesn't support non script items yet
SceneObjectPart op = World.GetSceneObjectPart(objectID);
foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
{
if (item.Value.Name == sound)
{
soundID = item.Value.ItemID;
break;
}
}
}
List<ScenePresence> avatarts = World.GetAvatars();
foreach (ScenePresence p in avatarts)
{
// TODO: some filtering by distance of avatar
p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags);
}
} }
public void llLoopSound(string sound, double volume) public void llLoopSound(string sound, double volume)
@ -928,7 +961,38 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llTriggerSound(string sound, double volume) public void llTriggerSound(string sound, double volume)
{ {
NotImplemented("llTriggerSound"); if (volume > 1)
volume = 1;
if (volume < 0)
volume = 0;
LLUUID ownerID = m_host.OwnerID;
LLUUID objectID = m_host.UUID;
LLUUID parentID = this.m_host.GetRootPartUUID();
LLUUID soundID = LLUUID.Zero;
LLVector3 position = this.m_host.AbsolutePosition; // region local
ulong regionHandle = World.RegionInfo.RegionHandle;
if (!LLUUID.TryParse(sound, out soundID))
{
// search sound file from inventory
SceneObjectPart op = World.GetSceneObjectPart(objectID);
foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
{
if (item.Value.Name == sound)
{
soundID = item.Value.ItemID;
break;
}
}
}
List<ScenePresence> avatarts = World.GetAvatars();
foreach (ScenePresence p in avatarts)
{
// TODO: some filtering by distance of avatar
p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume);
}
} }
public void llStopSound() public void llStopSound()
@ -938,7 +1002,31 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llPreloadSound(string sound) public void llPreloadSound(string sound)
{ {
NotImplemented("llPreloadSound"); LLUUID ownerID = m_host.OwnerID;
LLUUID objectID = m_host.UUID;
LLUUID soundID = LLUUID.Zero;
if (!LLUUID.TryParse(sound, out soundID))
{
//Trys to fetch sound id from prim's inventory.
//Prim's inventory doesn't support non script items yet
SceneObjectPart op = World.GetSceneObjectPart(objectID);
foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory)
{
if (item.Value.Name == sound)
{
soundID = item.Value.ItemID;
break;
}
}
}
List<ScenePresence> avatarts = World.GetAvatars();
foreach (ScenePresence p in avatarts)
{
// TODO: some filtering by distance of avatar
p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
}
} }
public string llGetSubString(string src, int start, int end) public string llGetSubString(string src, int start, int end)

View File

@ -1171,6 +1171,7 @@
<Reference name="libsecondlife.dll"/> <Reference name="libsecondlife.dll"/>
<Reference name="OpenSim" /> <Reference name="OpenSim" />
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Region.Environment" /> <Reference name="OpenSim.Region.Environment" />
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="Axiom.MathLib.dll" localCopy="false"/> <Reference name="Axiom.MathLib.dll" localCopy="false"/>