From 5a96ef52cb552c835cc109cb005db989eade5803 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Oct 2012 18:41:47 +0000 Subject: [PATCH 01/55] Deep copy the collection of at_target objects so it can't be modified while it's being iterated --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9c61fe7da8..2cdc4b301d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1692,9 +1692,12 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAtTargets() { - Dictionary.ValueCollection objs; + List objs = new List(); lock (m_groupsWithTargets) - objs = m_groupsWithTargets.Values; + { + foreach (SceneObjectGroup grp in m_groupsWithTargets.Values) + objs.Add(grp); + } foreach (SceneObjectGroup entry in objs) entry.checkAtTargets(); From c97890ca69df91e6590ac7dd234a3e86cf7fbaf1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 29 Oct 2012 22:53:06 +0000 Subject: [PATCH 02/55] Add "force gc" region console command which manually invokes garbage collection. For debugging purposes. --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 11 +++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index aac9c45fb7..5b2d7dc6d8 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -192,8 +192,19 @@ namespace OpenSim.Framework.Servers "threads show", "Show thread status. Synonym for \"show threads\"", (string module, string[] args) => Notice(GetThreadsReport())); + + m_console.Commands.AddCommand("General", false, "force gc", + "force gc", + "Manually invoke runtime garbage collection. For debugging purposes", + HandleForceGc); } } + + private void HandleForceGc(string module, string[] args) + { + MainConsole.Instance.Output("Manually invoking runtime garbage collection"); + GC.Collect(); + } /// /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b6d0a3b661..aa82af41c1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -74,8 +74,9 @@ namespace OpenSim.Region.Framework.Scenes { // ~ScenePresence() // { -// m_log.Debug("[SCENE PRESENCE] Destructor called"); +// m_log.DebugFormat("[SCENE PRESENCE]: Destructor called on {0}", Name); // } + private void TriggerScenePresenceUpdated() { if (m_scene != null) From 09f4e72d6af4b86238af516b1719ff4f63aa7174 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 29 Oct 2012 23:22:40 +0000 Subject: [PATCH 03/55] Fix memory leak where removing an NPC did not remove its circuits. This was because we were removing by circuitcode where NPCs have no code. Now removing by agent ID instead. This commit also fixes the "show circuits" console command to work properly where the circuit has no associated IP address. --- OpenSim/Region/Application/OpenSim.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++-- .../OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index b24641a454..2236e4388a 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -1111,7 +1111,7 @@ namespace OpenSim aCircuit.Name, aCircuit.child ? "child" : "root", aCircuit.circuitcode.ToString(), - aCircuit.IPAddress.ToString(), + aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set", aCircuit.Viewer); }); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2cdc4b301d..7d8cbf5804 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3384,9 +3384,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - // We remove the acd up here to avoid later raec conditions if two RemoveClient() calls occurred + // We remove the acd up here to avoid later race conditions if two RemoveClient() calls occurred // simultaneously. - m_authenticateHandler.RemoveCircuit(acd.circuitcode); + // We also need to remove by agent ID since NPCs will have no circuit code. + m_authenticateHandler.RemoveCircuit(agentID); } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 91799667ab..52ed8468c6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -117,6 +117,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); + + IClientAPI client; + Assert.That(m_scene.TryGetClient(npcId, out client), Is.True); + + // Have to account for both SP and NPC. + Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2)); } [Test] @@ -136,6 +142,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests ScenePresence deletedNpc = m_scene.GetScenePresence(npcId); Assert.That(deletedNpc, Is.Null); + IClientAPI client; + Assert.That(m_scene.TryGetClient(npcId, out client), Is.False); + + // Have to account for SP still present. + Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); } [Test] From 7560010f340e9e67e0fb87d0e3863ed69bdbedf1 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Thu, 4 Oct 2012 11:33:21 +0100 Subject: [PATCH 04/55] Immediately setting gain to zero as a workaround for code not stopping sound started by llPlaySound --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fa57845c7d..bedcd85d38 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2452,6 +2452,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStopSound() { m_host.AddScriptLPS(1); + m_host.AdjustSoundGain(0); if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) { if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) From ed162a10beaa8bcab1c51f03a51acf5a9537eaae Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 13:50:12 +0100 Subject: [PATCH 05/55] Converting the ISoundModule implementation from an IRegionModule to an INonSharedRegionModule --- ...SoundModule.cs => SoundModuleNonShared.cs} | 78 ++++++++++++++----- 1 file changed, 58 insertions(+), 20 deletions(-) rename OpenSim/Region/CoreModules/World/Sound/{SoundModule.cs => SoundModuleNonShared.cs} (78%) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs similarity index 78% rename from OpenSim/Region/CoreModules/World/Sound/SoundModule.cs rename to OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index a2f09507ef..9fd0a36561 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -24,43 +24,79 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - using System; +using System.Reflection; + using Nini.Config; using OpenMetaverse; +using log4net; +using Mono.Addins; + using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using System.Reflection; -using log4net; namespace OpenSim.Region.CoreModules.World.Sound { - public class SoundModule : IRegionModule, ISoundModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SoundModuleNonShared")] + public class SoundModuleNonShared : INonSharedRegionModule, ISoundModule { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Scene m_scene; - - public void Initialise(Scene scene, IConfigSource source) + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + + public bool Enabled { get; private set; } + + #region INonSharedRegionModule + + public void Initialise(IConfigSource configSource) { + IConfig config = configSource.Configs["Sounds"]; + + Enabled = (config != null && config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared"); + } + + public void AddRegion(Scene scene) { } + + public void RemoveRegion(Scene scene) + { + m_scene.EventManager.OnClientLogin -= OnNewClient; + } + + public void RegionLoaded(Scene scene) + { + if (!Enabled) + return; + m_scene = scene; - - m_scene.EventManager.OnNewClient += OnNewClient; - + m_scene.EventManager.OnClientLogin += OnNewClient; + m_scene.RegisterModuleInterface(this); } - - public void PostInitialise() {} - public void Close() {} + + public void Close() { } + + public Type ReplaceableInterface + { + get { return typeof(ISoundModule); } + } + public string Name { get { return "Sound Module"; } } - public bool IsSharedModule { get { return false; } } - + + #endregion + + #region Event Handlers + private void OnNewClient(IClientAPI client) { client.OnSoundTrigger += TriggerSound; } - + + #endregion + + #region ISoundModule + public virtual void PlayAttachedSound( UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) { @@ -96,7 +132,7 @@ namespace OpenSim.Region.CoreModules.World.Sound sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags); }); } - + public virtual void TriggerSound( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) { @@ -137,5 +173,7 @@ namespace OpenSim.Region.CoreModules.World.Sound soundId, ownerID, objectID, parentID, handle, position, thisSpGain); }); } + + #endregion } } From 375fb6658909f619f3210590743c228834d0d2c0 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:01:29 +0100 Subject: [PATCH 06/55] making the max distance for sounds to be heard from their origin a configurable option exposed via a public field on ISoundModule (with private setter in the implementation) --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 12 +++++++++--- OpenSim/Region/Framework/Interfaces/ISoundModule.cs | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 9fd0a36561..ff052baaaa 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -48,13 +48,19 @@ namespace OpenSim.Region.CoreModules.World.Sound public bool Enabled { get; private set; } + public float MaxDistance { get; private set; } + #region INonSharedRegionModule public void Initialise(IConfigSource configSource) { IConfig config = configSource.Configs["Sounds"]; - Enabled = (config != null && config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared"); + if (config == null) + return; + + Enabled = config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared"; + MaxDistance = config.GetFloat("MaxDistance", 100.0f); } public void AddRegion(Scene scene) { } @@ -109,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Sound m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); - if (dis > 100.0) // Max audio distance + if (dis > MaxDistance) // Max audio distance return; if (grp.IsAttachment) @@ -158,7 +164,7 @@ namespace OpenSim.Region.CoreModules.World.Sound { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); - if (dis > 100.0) // Max audio distance + if (dis > MaxDistance) // Max audio distance return; float thisSpGain; diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 6117a80d9e..4c558ccea1 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -32,6 +32,8 @@ namespace OpenSim.Region.Framework.Interfaces { public interface ISoundModule { + float MaxDistance { get; } + void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius); void TriggerSound( From 6bd1f0f209bce2f158c881f525235078957e9a62 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:04:28 +0100 Subject: [PATCH 07/55] Factoring out an if-else block in PlayAttachedSound as it was using the previously hard-coded max distance value. --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index ff052baaaa..f3ec572c10 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -112,6 +112,9 @@ namespace OpenSim.Region.CoreModules.World.Sound SceneObjectGroup grp = part.ParentGroup; + if (radius == 0) + radius = MaxDistance; + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); @@ -130,9 +133,6 @@ namespace OpenSim.Region.CoreModules.World.Sound float thisSpGain; // Scale by distance - if (radius == 0) - thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0)); - else thisSpGain = (float)((double)gain * ((radius - dis) / radius)); sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags); @@ -160,6 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Sound } } + if (radius == 0) + radius = MaxDistance; + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); @@ -170,9 +173,6 @@ namespace OpenSim.Region.CoreModules.World.Sound float thisSpGain; // Scale by distance - if (radius == 0) - thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0)); - else thisSpGain = (float)((double)gain * ((radius - dis) / radius)); sp.ControllingClient.SendTriggeredSound( From 20be6a4b48d73734e0041780868ff60078163004 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:13:38 +0100 Subject: [PATCH 08/55] refactoring thisSpGain in PlayAttachedSound as it was previously using two typecasts in the assignment and had the assignment on a separate line to the declaration --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index f3ec572c10..14914b69dd 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -130,12 +130,10 @@ namespace OpenSim.Region.CoreModules.World.Sound dis = 0; } - float thisSpGain; - // Scale by distance - thisSpGain = (float)((double)gain * ((radius - dis) / radius)); + double thisSpGain = gain * ((radius - dis) / radius); - sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags); + sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)thisSpGain, flags); }); } @@ -170,13 +168,11 @@ namespace OpenSim.Region.CoreModules.World.Sound if (dis > MaxDistance) // Max audio distance return; - float thisSpGain; - // Scale by distance - thisSpGain = (float)((double)gain * ((radius - dis) / radius)); + double thisSpGain = gain * ((radius - dis) / radius); sp.ControllingClient.SendTriggeredSound( - soundId, ownerID, objectID, parentID, handle, position, thisSpGain); + soundId, ownerID, objectID, parentID, handle, position, (float)thisSpGain); }); } From 1d47bcb6b6838500fa9b80d441a8b87ceaf0e01c Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:14:01 +0100 Subject: [PATCH 09/55] stripping whitespace from ISoundModule, formatting SoundModuleNonShared.cs --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 8 +++++--- OpenSim/Region/Framework/Interfaces/ISoundModule.cs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 14914b69dd..74f2874b99 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -133,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World.Sound // Scale by distance double thisSpGain = gain * ((radius - dis) / radius); - sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)thisSpGain, flags); + sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, + ownerID, (float)thisSpGain, flags); }); } @@ -171,8 +172,9 @@ namespace OpenSim.Region.CoreModules.World.Sound // Scale by distance double thisSpGain = gain * ((radius - dis) / radius); - sp.ControllingClient.SendTriggeredSound( - soundId, ownerID, objectID, parentID, handle, position, (float)thisSpGain); + sp.ControllingClient.SendTriggeredSound(soundId, ownerID, + objectID, parentID, handle, position, + (float)thisSpGain); }); } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 4c558ccea1..945029f89e 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces float MaxDistance { get; } void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius); - + void TriggerSound( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius); } From 516ee244b4f8f493b9b76a62b62f4e8304826e4f Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:30:51 +0100 Subject: [PATCH 10/55] swapping GetSceneObjectPart for TryGetSceneObjectPart in PlayAttachedSound to imply why we're doing an early return. --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 74f2874b99..917b3dc168 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -106,8 +106,8 @@ namespace OpenSim.Region.CoreModules.World.Sound public virtual void PlayAttachedSound( UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) { - SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); - if (part == null) + SceneObjectPart part; + if (!m_scene.TryGetSceneObjectPart(objectID, out part)) return; SceneObjectGroup grp = part.ParentGroup; @@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Sound public virtual void TriggerSound( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) { - SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); - if (part == null) + SceneObjectPart part; + if (!m_scene.TryGetSceneObjectPart(objectID, out part)) { ScenePresence sp; if (!m_scene.TryGetScenePresence(objectID, out sp)) From 644089278814a269d30fe8198e6a000e6e3153e7 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:31:50 +0100 Subject: [PATCH 11/55] TryGetScenePresence in TriggerSound is probably meant to be using the ownerID, not the objectID --- OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 917b3dc168..f0e446fbc1 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -145,7 +145,7 @@ namespace OpenSim.Region.CoreModules.World.Sound if (!m_scene.TryGetSceneObjectPart(objectID, out part)) { ScenePresence sp; - if (!m_scene.TryGetScenePresence(objectID, out sp)) + if (!m_scene.TryGetScenePresence(ownerID, out sp)) return; } else From b42cfe49a2f4e95687eb76381ed911515ef2e3b2 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:37:01 +0100 Subject: [PATCH 12/55] Replacing double-if block in SceneObjectPart.SendSound with Util.Clip --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 27ef4c9b11..a539effa12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2684,10 +2684,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster) { - if (volume > 1) - volume = 1; - if (volume < 0) - volume = 0; + volume = Util.Clip((float)volume, 0, 1); UUID ownerID = OwnerID; UUID objectID = ParentGroup.RootPart.UUID; From f4fe8763ad4f4cb85ff38eb65f1138baee74ece1 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:37:55 +0100 Subject: [PATCH 13/55] Changing the logic order in the TaskInventory iterator of ScenObjectPart.SendSound, since we can currently have non-unique object inventory names so we should check the asset type first. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a539effa12..681feea4be 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2701,7 +2701,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (KeyValuePair item in TaskInventory) { - if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) + if (item.Value.Type == (int)AssetType.Sound && item.Value.Name == sound) { soundID = item.Value.ItemID; break; From 32db725dd770a52d02f86cf8a1274f68178d6844 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:39:06 +0100 Subject: [PATCH 14/55] SceneObjectPart.SendSound can exit early if a sound module was not found. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 681feea4be..3a39da0102 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2684,6 +2684,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster) { + ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); + if(soundModule == null) + return; + volume = Util.Clip((float)volume, 0, 1); UUID ownerID = OwnerID; @@ -2713,9 +2717,6 @@ namespace OpenSim.Region.Framework.Scenes if (soundID == UUID.Zero) return; - ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); - if (soundModule != null) - { if (useMaster) { if (isMaster) @@ -2761,7 +2762,6 @@ namespace OpenSim.Region.Framework.Scenes else soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); } - } } /// From 1c618843b836c4e9ad8ae685d2f49836e32d8b08 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:39:23 +0100 Subject: [PATCH 15/55] formatting changes to SceneObjectPart.SendSound; consistent indentation --- .../Framework/Scenes/SceneObjectPart.cs | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3a39da0102..b333a1a5af 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2717,51 +2717,51 @@ namespace OpenSim.Region.Framework.Scenes if (soundID == UUID.Zero) return; - if (useMaster) - { - if (isMaster) - { - if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); - ParentGroup.PlaySoundMasterPrim = this; - ownerID = OwnerID; - objectID = ParentGroup.RootPart.UUID; - parentID = ParentGroup.UUID; - position = AbsolutePosition; // region local - regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; - if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); - foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) - { - ownerID = prim.OwnerID; - objectID = prim.ParentGroup.RootPart.UUID; - parentID = prim.ParentGroup.UUID; - position = prim.AbsolutePosition; // region local - regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle; - if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); - } - ParentGroup.PlaySoundSlavePrims.Clear(); - ParentGroup.PlaySoundMasterPrim = null; - } - else - { - ParentGroup.PlaySoundSlavePrims.Add(this); - } - } - else + if (useMaster) + { + if (isMaster) { if (triggered) soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); else soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + ParentGroup.PlaySoundMasterPrim = this; + ownerID = OwnerID; + objectID = ParentGroup.RootPart.UUID; + parentID = ParentGroup.UUID; + position = AbsolutePosition; // region local + regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; + if (triggered) + soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + else + soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) + { + ownerID = prim.OwnerID; + objectID = prim.ParentGroup.RootPart.UUID; + parentID = prim.ParentGroup.UUID; + position = prim.AbsolutePosition; // region local + regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle; + if (triggered) + soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + else + soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + } + ParentGroup.PlaySoundSlavePrims.Clear(); + ParentGroup.PlaySoundMasterPrim = null; } + else + { + ParentGroup.PlaySoundSlavePrims.Add(this); + } + } + else + { + if (triggered) + soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + else + soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + } } /// From d4034271eb37ff31cbdcad416a00f4e4c426731e Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:42:59 +0100 Subject: [PATCH 16/55] formatting ISoundModule prior to documentation --- OpenSim/Region/Framework/Interfaces/ISoundModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 945029f89e..90fe0bcd55 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -34,9 +34,11 @@ namespace OpenSim.Region.Framework.Interfaces { float MaxDistance { get; } - void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius); + void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, + double gain, Vector3 position, byte flags, float radius); void TriggerSound( - UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius); + UUID soundId, UUID ownerID, UUID objectID, UUID parentID, + double gain, Vector3 position, UInt64 handle, float radius); } } \ No newline at end of file From b9e0f1cd2be3fe8b20d639d66f5f4fc8f1995d73 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:46:31 +0100 Subject: [PATCH 17/55] documenting ISoundModule methods & fields --- .../Framework/Interfaces/ISoundModule.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 90fe0bcd55..6930d7806b 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -32,11 +32,39 @@ namespace OpenSim.Region.Framework.Interfaces { public interface ISoundModule { + /// + /// Maximum distance between a sound source and a recipient. + /// float MaxDistance { get; } + /// + /// Play a sound from an object. + /// + /// Sound asset ID + /// Sound source owner + /// Sound source ID + /// Sound volume + /// Sound source position + /// Sound flags + /// + /// Radius used to affect gain over distance. + /// void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius); + /// + /// Trigger a sound in the scene. + /// + /// Sound asset ID + /// Sound source owner + /// Sound source ID + /// Sound source parent. + /// Sound volume + /// Sound source position + /// + /// + /// Radius used to affect gain over distance. + /// void TriggerSound( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius); From 206a694c6baf9603855cc8eab50909e5e63b0f10 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:50:31 +0100 Subject: [PATCH 18/55] moving comment for llStopSound inside the method block prior to transposition to sound module --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bedcd85d38..7fa01c1a67 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2448,11 +2448,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false); } - // Xantor 20080528: Clear prim data of sound instead public void llStopSound() { m_host.AddScriptLPS(1); m_host.AdjustSoundGain(0); + // Xantor 20080528: Clear prim data of sound instead if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) { if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) From 8763a637b5c2e48a97111b4f569e71b7e1c2f1d2 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 14:55:00 +0100 Subject: [PATCH 19/55] transposing stop sound into sound module --- .../World/Sound/SoundModuleNonShared.cs | 45 +++++++++++++++++++ .../Framework/Interfaces/ISoundModule.cs | 6 +++ .../Shared/Api/Implementation/LSL_Api.cs | 42 +++-------------- 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index f0e446fbc1..670794d94a 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -178,6 +178,51 @@ namespace OpenSim.Region.CoreModules.World.Sound }); } + public virtual void StopSound(UUID objectID) + { + SceneObjectPart m_host; + if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) + return; + + m_host.AdjustSoundGain(0); + // Xantor 20080528: Clear prim data of sound instead + if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) + { + if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) + { + foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) + { + part.Sound = UUID.Zero; + part.SoundGain = 0; + part.SoundFlags = 0; + part.SoundRadius = 0; + part.ScheduleFullUpdate(); + part.SendFullUpdateToAllClients(); + } + m_host.ParentGroup.LoopSoundMasterPrim = null; + m_host.ParentGroup.LoopSoundSlavePrims.Clear(); + } + else + { + m_host.Sound = UUID.Zero; + m_host.SoundGain = 0; + m_host.SoundFlags = 0; + m_host.SoundRadius = 0; + m_host.ScheduleFullUpdate(); + m_host.SendFullUpdateToAllClients(); + } + } + else + { + m_host.Sound = UUID.Zero; + m_host.SoundGain = 0; + m_host.SoundFlags = 0; + m_host.SoundRadius = 0; + m_host.ScheduleFullUpdate(); + m_host.SendFullUpdateToAllClients(); + } + } + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 6930d7806b..45219eddd3 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -68,5 +68,11 @@ namespace OpenSim.Region.Framework.Interfaces void TriggerSound( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius); + + /// + /// Stop sounds eminating from an object. + /// + /// Sound source ID + void StopSound(UUID objectID); } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7fa01c1a67..25be3ffa4f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -107,6 +107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected IUrlModule m_UrlModule = null; protected Dictionary m_userInfoCache = new Dictionary(); protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. + protected ISoundModule m_SoundModule = null; public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { @@ -119,6 +120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_TransferModule = m_ScriptEngine.World.RequestModuleInterface(); m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); + m_SoundModule = m_ScriptEngine.World.RequestModuleInterface(); AsyncCommands = new AsyncCommandManager(ScriptEngine); } @@ -2451,43 +2453,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llStopSound() { m_host.AddScriptLPS(1); - m_host.AdjustSoundGain(0); - // Xantor 20080528: Clear prim data of sound instead - if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) - { - if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) - { - foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) - { - part.Sound = UUID.Zero; - part.SoundGain = 0; - part.SoundFlags = 0; - part.SoundRadius = 0; - part.ScheduleFullUpdate(); - part.SendFullUpdateToAllClients(); - } - m_host.ParentGroup.LoopSoundMasterPrim = null; - m_host.ParentGroup.LoopSoundSlavePrims.Clear(); - } - else - { - m_host.Sound = UUID.Zero; - m_host.SoundGain = 0; - m_host.SoundFlags = 0; - m_host.SoundRadius = 0; - m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); - } - } - else - { - m_host.Sound = UUID.Zero; - m_host.SoundGain = 0; - m_host.SoundFlags = 0; - m_host.SoundRadius = 0; - m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); - } + + if (m_SoundModule != null) + m_SoundModule.StopSound(m_host.UUID); } public void llPreloadSound(string sound) From a68e2fe1692a7611c58f774ac5b94c4298343433 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 15:16:30 +0100 Subject: [PATCH 20/55] transposing preload sound onto sound module --- .../World/Sound/SoundModuleNonShared.cs | 20 ++++++++++++ .../Framework/Interfaces/ISoundModule.cs | 10 ++++++ .../Framework/Scenes/SceneObjectPart.cs | 31 ------------------- .../Shared/Api/Implementation/LSL_Api.cs | 3 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 670794d94a..0225d6f77b 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -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 } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 45219eddd3..0f6576345a 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -74,5 +74,15 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Sound source ID void StopSound(UUID objectID); + + /// + /// Preload sound to viewers within range. + /// + /// Sound asset ID + /// Sound source ID + /// + /// Radius used to determine which viewers should preload the sound. + /// + void PreloadSound(UUID soundID, UUID objectID, float radius); } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b333a1a5af..48615decc9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -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 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; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 25be3ffa4f..61fd1aa552 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -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); } From 29a8ae48b51de55a02f839b6e4566054ad3f7f58 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 6 Oct 2012 22:23:14 +0100 Subject: [PATCH 21/55] transposing LoopSoundMaster to Sound Module --- .../World/Sound/SoundModuleNonShared.cs | 36 +++++++++++++++++++ .../Framework/Interfaces/ISoundModule.cs | 11 ++++++ .../Shared/Api/Implementation/LSL_Api.cs | 28 ++------------- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 0225d6f77b..4912ed8361 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -243,6 +243,42 @@ namespace OpenSim.Region.CoreModules.World.Sound }); } + public virtual void LoopSoundMaster(UUID objectID, UUID soundID, + double volume, double radius) + { + SceneObjectPart m_host; + if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) + return; + + m_host.ParentGroup.LoopSoundMasterPrim = m_host; + lock (m_host.ParentGroup.LoopSoundSlavePrims) + { + foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) + { + if (prim.Sound != UUID.Zero) + StopSound(objectID); + + prim.Sound = soundID; + prim.SoundGain = volume; + prim.SoundFlags = 1; // looping + prim.SoundRadius = radius; + + prim.ScheduleFullUpdate(); + prim.SendFullUpdateToAllClients(); + } + } + if (m_host.Sound != UUID.Zero) + StopSound(objectID); + + m_host.Sound = soundID; + m_host.SoundGain = volume; + m_host.SoundFlags = 1; // looping + m_host.SoundRadius = radius; + + m_host.ScheduleFullUpdate(); + m_host.SendFullUpdateToAllClients(); + } + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 0f6576345a..d2557b59fa 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -84,5 +84,16 @@ namespace OpenSim.Region.Framework.Interfaces /// Radius used to determine which viewers should preload the sound. /// void PreloadSound(UUID soundID, UUID objectID, float radius); + + /// + /// Declare object as new sync master, play specified sound at + /// specified volume with specified radius. + /// + /// Sound source ID + /// Sound asset ID + /// Sound volume + /// Sound radius + void LoopSoundMaster(UUID objectID, UUID soundID, double gain, + double radius); } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 61fd1aa552..2669add8f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2397,33 +2397,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLoopSoundMaster(string sound, double volume) { m_host.AddScriptLPS(1); - m_host.ParentGroup.LoopSoundMasterPrim = m_host; - lock (m_host.ParentGroup.LoopSoundSlavePrims) + if (m_SoundModule != null) { - foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) - { - if (prim.Sound != UUID.Zero) - llStopSound(); - - prim.Sound = KeyOrName(sound); - prim.SoundGain = volume; - prim.SoundFlags = 1; // looping - prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? - - prim.ScheduleFullUpdate(); - prim.SendFullUpdateToAllClients(); - } + m_SoundModule.LoopSoundMaster(m_host.UUID, KeyOrName(sound), + volume, 20); } - if (m_host.Sound != UUID.Zero) - llStopSound(); - - m_host.Sound = KeyOrName(sound); - m_host.SoundGain = volume; - m_host.SoundFlags = 1; // looping - m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? - - m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); } public void llLoopSoundSlave(string sound, double volume) From d7ffcace8f596d9b0cf84f1e8cbe4e2d6a71baef Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 6 Oct 2012 22:27:20 +0100 Subject: [PATCH 22/55] adjusting parameter order of PreloadSound to be more logical --- .../Region/CoreModules/World/Sound/SoundModuleNonShared.cs | 2 +- OpenSim/Region/Framework/Interfaces/ISoundModule.cs | 4 ++-- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 4912ed8361..5a560d8fc2 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.World.Sound } } - public virtual void PreloadSound(UUID soundID, UUID objectID, float radius) + public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) { SceneObjectPart part; if (soundID == UUID.Zero diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index d2557b59fa..d34a520fc4 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -78,12 +78,12 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Preload sound to viewers within range. /// - /// Sound asset ID /// Sound source ID + /// Sound asset ID /// /// Radius used to determine which viewers should preload the sound. /// - void PreloadSound(UUID soundID, UUID objectID, float radius); + void PreloadSound(UUID objectID, UUID soundID, float radius); /// /// Declare object as new sync master, play specified sound at diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2669add8f8..02521450e2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2440,7 +2440,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); if (m_SoundModule != null) - m_SoundModule.PreloadSound(KeyOrName(sound), m_host.UUID, 0); + m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0); ScriptSleep(1000); } From e5df8cafb8d2cc813824299fe4714ee0ceee30c3 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 6 Oct 2012 22:37:27 +0100 Subject: [PATCH 23/55] Removing a locked iteration over SceneObjectGroup.LoopSoundSlavePrims as the SL Wiki spec does not state that slaves are set to match master values --- .../World/Sound/SoundModuleNonShared.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 5a560d8fc2..7ce13d1aa1 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -251,22 +251,7 @@ namespace OpenSim.Region.CoreModules.World.Sound return; m_host.ParentGroup.LoopSoundMasterPrim = m_host; - lock (m_host.ParentGroup.LoopSoundSlavePrims) - { - foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) - { - if (prim.Sound != UUID.Zero) - StopSound(objectID); - prim.Sound = soundID; - prim.SoundGain = volume; - prim.SoundFlags = 1; // looping - prim.SoundRadius = radius; - - prim.ScheduleFullUpdate(); - prim.SendFullUpdateToAllClients(); - } - } if (m_host.Sound != UUID.Zero) StopSound(objectID); From 3d8f59aac38e57cf573809b0456053aa0cc8500d Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 6 Oct 2012 22:40:26 +0100 Subject: [PATCH 24/55] refactoring StopSound into a private static method to skip repeating m_scene.TryGetSceneObjectPart --- .../Region/CoreModules/World/Sound/SoundModuleNonShared.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 7ce13d1aa1..b4b8e7999d 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -185,6 +185,11 @@ namespace OpenSim.Region.CoreModules.World.Sound if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) return; + StopSound(m_host); + } + + private static void StopSound(SceneObjectPart m_host) + { m_host.AdjustSoundGain(0); // Xantor 20080528: Clear prim data of sound instead if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) @@ -253,7 +258,7 @@ namespace OpenSim.Region.CoreModules.World.Sound m_host.ParentGroup.LoopSoundMasterPrim = m_host; if (m_host.Sound != UUID.Zero) - StopSound(objectID); + StopSound(m_host); m_host.Sound = soundID; m_host.SoundGain = volume; From 22693304fb3cfbb8d073c48affd2e56453dd2b2f Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 15 Oct 2012 14:05:17 +0100 Subject: [PATCH 25/55] removing superfluous lines from SceneObjectPart.SendSound --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 48615decc9..681c7259da 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2695,11 +2695,6 @@ namespace OpenSim.Region.Framework.Scenes else soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); ParentGroup.PlaySoundMasterPrim = this; - ownerID = OwnerID; - objectID = ParentGroup.RootPart.UUID; - parentID = ParentGroup.UUID; - position = AbsolutePosition; // region local - regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; if (triggered) soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); else @@ -2707,10 +2702,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) { ownerID = prim.OwnerID; - objectID = prim.ParentGroup.RootPart.UUID; - parentID = prim.ParentGroup.UUID; position = prim.AbsolutePosition; // region local - regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle; if (triggered) soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); else From 9df510157e26ffcaf04fd4b85512778fddc08f68 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 15 Oct 2012 14:28:34 +0100 Subject: [PATCH 26/55] deduplicating code into a single LoopSound method --- .../World/Sound/SoundModuleNonShared.cs | 13 +++++++-- .../Framework/Interfaces/ISoundModule.cs | 9 +++--- .../Shared/Api/Implementation/LSL_Api.cs | 28 +++++-------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index b4b8e7999d..6f35a230bd 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -248,13 +248,22 @@ namespace OpenSim.Region.CoreModules.World.Sound }); } - public virtual void LoopSoundMaster(UUID objectID, UUID soundID, - double volume, double radius) + // Xantor 20080528 we should do this differently. + // 1) apply the sound to the object + // 2) schedule full update + // just sending the sound out once doesn't work so well when other avatars come in view later on + // or when the prim gets moved, changed, sat on, whatever + // see large number of mantises (mantes?) + // 20080530 Updated to remove code duplication + // 20080530 Stop sound if there is one, otherwise volume only changes don't work + public void LoopSound(UUID objectID, UUID soundID, + double volume, double radius, bool isMaster) { SceneObjectPart m_host; if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) return; + if (isMaster) m_host.ParentGroup.LoopSoundMasterPrim = m_host; if (m_host.Sound != UUID.Zero) diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index d34a520fc4..e514a59882 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -86,14 +86,15 @@ namespace OpenSim.Region.Framework.Interfaces void PreloadSound(UUID objectID, UUID soundID, float radius); /// - /// Declare object as new sync master, play specified sound at - /// specified volume with specified radius. + /// Loop specified sound at specified volume with specified radius, + /// optionally declaring object as new sync master. /// /// Sound source ID /// Sound asset ID /// Sound volume /// Sound radius - void LoopSoundMaster(UUID objectID, UUID soundID, double gain, - double radius); + /// Set object to sync master if true + void LoopSound(UUID objectID, UUID soundID, double gain, + double radius, bool isMaster); } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 02521450e2..c479944aee 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2370,28 +2370,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); } - // Xantor 20080528 we should do this differently. - // 1) apply the sound to the object - // 2) schedule full update - // just sending the sound out once doesn't work so well when other avatars come in view later on - // or when the prim gets moved, changed, sat on, whatever - // see large number of mantises (mantes?) - // 20080530 Updated to remove code duplication - // 20080530 Stop sound if there is one, otherwise volume only changes don't work public void llLoopSound(string sound, double volume) { m_host.AddScriptLPS(1); - - if (m_host.Sound != UUID.Zero) - llStopSound(); - - m_host.Sound = KeyOrName(sound); - m_host.SoundGain = volume; - m_host.SoundFlags = 1; // looping - m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? - - m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); + if (m_SoundModule != null) + { + m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), + volume, 20, false); + } } public void llLoopSoundMaster(string sound, double volume) @@ -2399,8 +2385,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - m_SoundModule.LoopSoundMaster(m_host.UUID, KeyOrName(sound), - volume, 20); + m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), + volume, 20, true); } } From e75596524a1d8f1a785d78eccdaf0fa585b703f8 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 15 Oct 2012 14:31:10 +0100 Subject: [PATCH 27/55] Formatting SoundModuleNonShared.LoopSound, consistent indentation --- OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 6f35a230bd..6f61c32762 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.World.Sound return; if (isMaster) - m_host.ParentGroup.LoopSoundMasterPrim = m_host; + m_host.ParentGroup.LoopSoundMasterPrim = m_host; if (m_host.Sound != UUID.Zero) StopSound(m_host); From 57940087d125cf817d1d2492145dc224439434ad Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 15 Oct 2012 15:09:45 +0100 Subject: [PATCH 28/55] Factoring out a superfluous local variable & repeated assignment in SceneObjectPart.SendSound as linksets are only meant to have a single owner --- .../Region/Framework/Scenes/SceneObjectPart.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 681c7259da..240cfa52d2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2659,7 +2659,6 @@ namespace OpenSim.Region.Framework.Scenes volume = Util.Clip((float)volume, 0, 1); - UUID ownerID = OwnerID; UUID objectID = ParentGroup.RootPart.UUID; UUID parentID = ParentGroup.UUID; @@ -2691,22 +2690,21 @@ namespace OpenSim.Region.Framework.Scenes if (isMaster) { if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); ParentGroup.PlaySoundMasterPrim = this; if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) { - ownerID = prim.OwnerID; position = prim.AbsolutePosition; // region local if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); } ParentGroup.PlaySoundSlavePrims.Clear(); ParentGroup.PlaySoundMasterPrim = null; @@ -2719,9 +2717,9 @@ namespace OpenSim.Region.Framework.Scenes else { if (triggered) - soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); } } From af39af1cc407b88d6d2838acff09de77d4a4335d Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 15 Oct 2012 16:11:26 +0100 Subject: [PATCH 29/55] fixing a bug in SceneObjectPart.SendSound where sounds would always come from the root prim rather than the source prim --- .../Region/Framework/Scenes/SceneObjectPart.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 240cfa52d2..5da4207683 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2659,7 +2659,6 @@ namespace OpenSim.Region.Framework.Scenes volume = Util.Clip((float)volume, 0, 1); - UUID objectID = ParentGroup.RootPart.UUID; UUID parentID = ParentGroup.UUID; UUID soundID = UUID.Zero; @@ -2690,21 +2689,21 @@ namespace OpenSim.Region.Framework.Scenes if (isMaster) { if (triggered) - soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius); ParentGroup.PlaySoundMasterPrim = this; if (triggered) - soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius); foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) { position = prim.AbsolutePosition; // region local if (triggered) - soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, prim.UUID, volume, position, flags, radius); } ParentGroup.PlaySoundSlavePrims.Clear(); ParentGroup.PlaySoundMasterPrim = null; @@ -2717,9 +2716,9 @@ namespace OpenSim.Region.Framework.Scenes else { if (triggered) - soundModule.TriggerSound(soundID, OwnerID, objectID, parentID, volume, position, regionHandle, radius); + soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius); else - soundModule.PlayAttachedSound(soundID, OwnerID, objectID, volume, position, flags, radius); + soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius); } } From 5abcecc7356bf58c479a7cff86581131a6ab3c9e Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:24:33 +0100 Subject: [PATCH 30/55] moving SendSound from SceneObjectPart to ISoundModule --- .../World/Sound/SoundModuleNonShared.cs | 73 +++++++++++++++ .../Framework/Interfaces/ISoundModule.cs | 15 ++++ .../Framework/Scenes/SceneObjectPart.cs | 88 ++----------------- .../Scripting/Minimodule/SOPObject.cs | 7 +- .../Shared/Api/Implementation/LSL_Api.cs | 22 +++-- 5 files changed, 119 insertions(+), 86 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 6f61c32762..37863ee21d 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -278,6 +278,79 @@ namespace OpenSim.Region.CoreModules.World.Sound m_host.SendFullUpdateToAllClients(); } + public void SendSound(UUID objectID, string sound, double volume, + bool triggered, byte flags, float radius, bool useMaster, + bool isMaster) + { + SceneObjectPart part; + if (!m_scene.TryGetSceneObjectPart(objectID, out part)) + return; + + volume = Util.Clip((float)volume, 0, 1); + + 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) + { + if (triggered) + TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); + else + PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); + part.ParentGroup.PlaySoundMasterPrim = part; + if (triggered) + TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); + else + PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); + foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims) + { + position = prim.AbsolutePosition; // region local + if (triggered) + TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius); + else + PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius); + } + part.ParentGroup.PlaySoundSlavePrims.Clear(); + part.ParentGroup.PlaySoundMasterPrim = null; + } + else + { + part.ParentGroup.PlaySoundSlavePrims.Add(part); + } + } + else + { + if (triggered) + TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); + else + PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); + } + } + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index e514a59882..c5edcb0cc1 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -96,5 +96,20 @@ namespace OpenSim.Region.Framework.Interfaces /// Set object to sync master if true void LoopSound(UUID objectID, UUID soundID, double gain, double radius, bool isMaster); + + /// + /// Trigger or play an attached sound in this part's inventory. + /// + /// + /// + /// + /// + /// + /// + /// + /// + void SendSound(UUID objectID, string sound, double volume, + bool triggered, byte flags, float radius, bool useMaster, + bool isMaster); } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5da4207683..cbb92b2627 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2239,7 +2239,15 @@ namespace OpenSim.Region.Framework.Scenes // play the sound. if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) - SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); + { + ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); + if (soundModule != null) + { + soundModule.SendSound(UUID, CollisionSound.ToString(), + CollisionSoundVolume, true, (byte)0, 0, false, + false); + } + } SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); @@ -2644,84 +2652,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Trigger or play an attached sound in this part's inventory. - /// - /// - /// - /// - /// - public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster) - { - ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface(); - if(soundModule == null) - return; - - volume = Util.Clip((float)volume, 0, 1); - - UUID parentID = ParentGroup.UUID; - - UUID soundID = UUID.Zero; - Vector3 position = AbsolutePosition; // region local - ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; - - if (!UUID.TryParse(sound, out soundID)) - { - // search sound file from inventory - lock (TaskInventory) - { - foreach (KeyValuePair item in 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) - { - if (triggered) - soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius); - ParentGroup.PlaySoundMasterPrim = this; - if (triggered) - soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius); - foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) - { - position = prim.AbsolutePosition; // region local - if (triggered) - soundModule.TriggerSound(soundID, OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, OwnerID, prim.UUID, volume, position, flags, radius); - } - ParentGroup.PlaySoundSlavePrims.Clear(); - ParentGroup.PlaySoundMasterPrim = null; - } - else - { - ParentGroup.PlaySoundSlavePrims.Add(this); - } - } - else - { - if (triggered) - soundModule.TriggerSound(soundID, OwnerID, UUID, parentID, volume, position, regionHandle, radius); - else - soundModule.PlayAttachedSound(soundID, OwnerID, UUID, volume, position, flags, radius); - } - } - /// /// Send a terse update to all clients /// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index aa23fee0c5..9e438e232f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -821,8 +821,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (!CanEdit()) return; - - GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false); + ISoundModule module = m_rootScene.RequestModuleInterface(); + if (module != null) + { + module.SendSound(GetSOP().UUID, asset.ToString(), volume, true, 0, 0, false, false); + } } #endregion diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c479944aee..f29be92ea5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2367,7 +2367,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // send the sound, once, to all clients in range - m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); + if (m_SoundModule != null) + { + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); + } } public void llLoopSound(string sound, double volume) @@ -2404,14 +2407,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // send the sound, once, to all clients in range - m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false); + if (m_SoundModule != null) + { + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, false, 0, 0, true, false); + } } public void llTriggerSound(string sound, double volume) { m_host.AddScriptLPS(1); - // send the sound, once, to all clients in range - m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false); + // 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); + } } public void llStopSound() @@ -5824,10 +5833,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Vector bottom_south_west) { m_host.AddScriptLPS(1); + if (m_SoundModule != null) + { float radius1 = (float)llVecDist(llGetPos(), top_north_east); float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); float radius = Math.Abs(radius1 - radius2); - m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false); + m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound).ToString(), volume, true, 0, radius, false, false); + } } public void llEjectFromLand(string pest) From c5af16aef82e2bdf2f4d877a231180e00a8893a6 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:40:21 +0100 Subject: [PATCH 31/55] shuffling code around so that the interface for ISoundModule.SendSound() specifies a UUID rather than a string --- .../World/Sound/SoundModuleNonShared.cs | 25 ++--------- .../Framework/Interfaces/ISoundModule.cs | 2 +- .../Framework/Scenes/SceneObjectPart.cs | 2 +- .../Scripting/Minimodule/SOPObject.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 44 +++++++++++++++++-- 5 files changed, 47 insertions(+), 28 deletions(-) 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); } } From c796f7861e318cc12248f3a86ee5b29e3fa99d79 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:44:09 +0100 Subject: [PATCH 32/55] 80-character width terminal formatting of recent commits to llPlaySound, llPlaySoundSlave, llTriggerSound and llTriggerSoundLimited --- .../Shared/Api/Implementation/LSL_Api.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 869d94efc9..610cb14ab6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2405,7 +2405,9 @@ 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, AssetType.Sound), volume, false, 0, 0, false, false); + m_SoundModule.SendSound(m_host.UUID, + KeyOrName(sound, AssetType.Sound), volume, false, 0, + 0, false, false); } } @@ -2445,7 +2447,9 @@ 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, AssetType.Sound), volume, false, 0, 0, true, false); + m_SoundModule.SendSound(m_host.UUID, + KeyOrName(sound, AssetType.Sound), volume, false, 0, + 0, true, false); } } @@ -2455,7 +2459,9 @@ 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, AssetType.Sound), volume, true, 0, 0, false, false); + m_SoundModule.SendSound(m_host.UUID, + KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, + false, false); } } @@ -5871,10 +5877,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - 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, AssetType.Sound), volume, true, 0, radius, false, false); + 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, AssetType.Sound), volume, true, 0, + radius, false, false); } } From f9923d4423f8f9dcf09a12e702737d2030a26d4a Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:45:30 +0100 Subject: [PATCH 33/55] shifting from two instances of typecasting to one instance of typecasting in llTriggerSoundLimited --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 610cb14ab6..2b6a3fdaef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5877,12 +5877,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - float radius1 = (float)llVecDist(llGetPos(), top_north_east); - float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); - float radius = Math.Abs(radius1 - radius2); + double radius1 = llVecDist(llGetPos(), top_north_east); + double radius2 = llVecDist(llGetPos(), bottom_south_west); + double radius = Math.Abs(radius1 - radius2); m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound, AssetType.Sound), volume, true, 0, - radius, false, false); + (float)radius, false, false); } } From af9dc483e9db950ca4187a7afe186da80d2c7acf Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:48:41 +0100 Subject: [PATCH 34/55] refactoring llGetPos() to take advantage of implicit converter --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2b6a3fdaef..2654b5a83a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2082,8 +2082,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetPos() { m_host.AddScriptLPS(1); - Vector3 pos = m_host.GetWorldPosition(); - return new LSL_Vector(pos.X, pos.Y, pos.Z); + return m_host.GetWorldPosition(); } public LSL_Vector llGetLocalPos() From ef157110897ef162c7f076d6d5f423b8cd9a8f47 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:49:25 +0100 Subject: [PATCH 35/55] refactoring llTriggerSoundLimited to not use the LSL methods, since that will cause unnecessary calls to m_host.AddScriptLPS(1) --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2654b5a83a..99b61890e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5876,8 +5876,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - double radius1 = llVecDist(llGetPos(), top_north_east); - double radius2 = llVecDist(llGetPos(), bottom_south_west); + double radius1 = VecDist(m_host.GetWorldPosition(), top_north_east); + double radius2 = VecDist(m_host.GetWorldPosition(), bottom_south_west); double radius = Math.Abs(radius1 - radius2); m_SoundModule.SendSound(m_host.UUID, KeyOrName(sound, AssetType.Sound), volume, true, 0, From 56965dd9599597bf5c51ab795f278db8291514c2 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 13:00:16 +0100 Subject: [PATCH 36/55] fixing poorly-formatted xml doc string for Util.IsInsideBox --- OpenSim/Framework/Util.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5c7797a95e..c369dbcd28 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -536,7 +536,7 @@ namespace OpenSim.Framework /// /// Determines whether a point is inside a bounding box. /// - /// /param> + /// /// /// /// From a9999a9676d46669150343e4cdbf65428326a91d Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 13:11:17 +0100 Subject: [PATCH 37/55] Refactoring llTriggerSoundLimited with a new method on ISoundModule, as the LL Wiki spec for llTriggerSoundLimited states an axis-aligned bounding box, not radial constraint --- .../World/Sound/SoundModuleNonShared.cs | 30 +++++++++++++++++++ .../Framework/Interfaces/ISoundModule.cs | 3 ++ .../Shared/Api/Implementation/LSL_Api.cs | 9 ++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 417c071147..ac7f7b4999 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -334,6 +334,36 @@ namespace OpenSim.Region.CoreModules.World.Sound } } + public void TriggerSoundLimited(UUID objectID, UUID sound, + double volume, Vector3 min, Vector3 max) + { + if (sound == UUID.Zero) + return; + + SceneObjectPart part; + if (!m_scene.TryGetSceneObjectPart(objectID, out part)) + return; + + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + { + double dis = Util.GetDistanceTo(sp.AbsolutePosition, + part.AbsolutePosition); + + if (dis > MaxDistance) // Max audio distance + return; + else if (!Util.IsInsideBox(sp.AbsolutePosition, min, max)) + return; + + // Scale by distance + double thisSpGain = volume * ((MaxDistance - dis) / MaxDistance); + + sp.ControllingClient.SendTriggeredSound(sound, part.OwnerID, + part.UUID, part.ParentGroup.UUID, + m_scene.RegionInfo.RegionHandle, + part.AbsolutePosition, (float)thisSpGain); + }); + } + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 5d1bb63ec7..2e53b16498 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -111,5 +111,8 @@ namespace OpenSim.Region.Framework.Interfaces void SendSound(UUID objectID, UUID sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster); + + void TriggerSoundLimited(UUID objectID, UUID sound, double volume, + Vector3 min, Vector3 max); } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 99b61890e5..aeb74a5e0a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5876,12 +5876,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - double radius1 = VecDist(m_host.GetWorldPosition(), top_north_east); - double radius2 = VecDist(m_host.GetWorldPosition(), bottom_south_west); - double radius = Math.Abs(radius1 - radius2); - m_SoundModule.SendSound(m_host.UUID, - KeyOrName(sound, AssetType.Sound), volume, true, 0, - (float)radius, false, false); + m_SoundModule.TriggerSoundLimited(m_host.UUID, + KeyOrName(sound, AssetType.Sound), volume, + bottom_south_west, top_north_east); } } From dcac2a7f716e512b604cce02768770e1660600eb Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 13:27:03 +0100 Subject: [PATCH 38/55] refactoring llCollisionSound to use new KeyOrName method --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index aeb74a5e0a..0fa247d338 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4342,16 +4342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // TODO: Parameter check logic required. - UUID soundId = UUID.Zero; - if (!UUID.TryParse(impact_sound, out soundId)) - { - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound); - - if (item != null && item.Type == (int)AssetType.Sound) - soundId = item.AssetID; - } - - m_host.CollisionSound = soundId; + m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); m_host.CollisionSoundVolume = (float)impact_volume; } From 2bb041925160922be669d7e185fb5da6df0efd29 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 14:30:33 +0100 Subject: [PATCH 39/55] documenting some params on ISoundModule methods --- .../Framework/Interfaces/ISoundModule.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 2e53b16498..68af4923d5 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -100,18 +100,27 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Trigger or play an attached sound in this part's inventory. /// - /// - /// - /// - /// + /// Sound source ID + /// Sound asset ID + /// Sound volume + /// Triggered or not. /// - /// - /// - /// + /// Sound radius + /// Play using sound master + /// Play as sound master void SendSound(UUID objectID, UUID sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster); + /// + /// Trigger a sound to be played to all agents within an axis-aligned + /// bounding box. + /// + /// Sound source ID + /// Sound asset ID + /// Sound volume + /// AABB bottom south-west corner + /// AABB top north-east corner void TriggerSoundLimited(UUID objectID, UUID sound, double volume, Vector3 min, Vector3 max); } From e0b5a3cd900d8ad29cdb7d43415b069d5484a424 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 15:15:03 +0100 Subject: [PATCH 40/55] tweaking configuration logic so that the INonSharedRegionModule will load by default --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 13 +++++++++---- bin/OpenSimDefaults.ini | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index ac7f7b4999..68bd413271 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -58,10 +58,15 @@ namespace OpenSim.Region.CoreModules.World.Sound IConfig config = configSource.Configs["Sounds"]; if (config == null) - return; - - Enabled = config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared"; - MaxDistance = config.GetFloat("MaxDistance", 100.0f); + { + Enabled = true; + MaxDistance = 100.0f; + } + else + { + Enabled = config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared"; + MaxDistance = config.GetFloat("MaxDistance", 100.0f); + } } public void AddRegion(Scene scene) { } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index dffc0ac565..afb6fedd7c 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1687,5 +1687,13 @@ Enabled = False ;; default is module is disabled at the top level AutoBackupModuleEnabled = false +[Sounds] + ;; {Module} {} {Implementation of ISoundModule to use.} {SoundModuleNonShared} + ;; Currently only INonSharedRegionModule module is implemented. + Module = SoundModuleNonShared + + ;; {MaxDistance} {} {Cut-off distance at which sounds will not be sent to users} {100.0} + MaxDistance = 100.0 + [Modules] Include-modules = "addon-modules/*/config/*.ini" From e308841de98ed3798b1c960c84831588b6598123 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 15:28:22 +0100 Subject: [PATCH 41/55] SianaGearz notes stop sound flag is 1 << 5, so using that for ISoundModule.StopSound rather than setting gain to zero --- .../CoreModules/World/Sound/SoundModuleNonShared.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 68bd413271..c163e86a50 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -204,8 +204,7 @@ namespace OpenSim.Region.CoreModules.World.Sound foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) { part.Sound = UUID.Zero; - part.SoundGain = 0; - part.SoundFlags = 0; + part.SoundFlags = 1 << 5; part.SoundRadius = 0; part.ScheduleFullUpdate(); part.SendFullUpdateToAllClients(); @@ -216,8 +215,7 @@ namespace OpenSim.Region.CoreModules.World.Sound else { m_host.Sound = UUID.Zero; - m_host.SoundGain = 0; - m_host.SoundFlags = 0; + m_host.SoundFlags = 1 << 5; m_host.SoundRadius = 0; m_host.ScheduleFullUpdate(); m_host.SendFullUpdateToAllClients(); @@ -226,8 +224,7 @@ namespace OpenSim.Region.CoreModules.World.Sound else { m_host.Sound = UUID.Zero; - m_host.SoundGain = 0; - m_host.SoundFlags = 0; + m_host.SoundFlags = 1 << 5; m_host.SoundRadius = 0; m_host.ScheduleFullUpdate(); m_host.SendFullUpdateToAllClients(); From a16ddbee4116fd1234bb2d53598616d5345c09c9 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 29 Oct 2012 16:05:02 +0000 Subject: [PATCH 42/55] Renaming module back to SoundModule as the hypothetical plan was to make another module using the shared region module interface, but this was pointed out by Melanie_T to be mostly pointless. --- .../World/Sound/{SoundModuleNonShared.cs => SoundModule.cs} | 6 +++--- bin/OpenSimDefaults.ini | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) rename OpenSim/Region/CoreModules/World/Sound/{SoundModuleNonShared.cs => SoundModule.cs} (98%) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs similarity index 98% rename from OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs rename to OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index c163e86a50..1db65193f1 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -39,8 +39,8 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.World.Sound { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SoundModuleNonShared")] - public class SoundModuleNonShared : INonSharedRegionModule, ISoundModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SoundModule")] + public class SoundModule : INonSharedRegionModule, ISoundModule { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); @@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.World.Sound } else { - Enabled = config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared"; + Enabled = config.GetString("Module", "SoundModule") == "SoundModule"; MaxDistance = config.GetFloat("MaxDistance", 100.0f); } } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index afb6fedd7c..6d1af7ce1a 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1688,9 +1688,8 @@ Enabled = False AutoBackupModuleEnabled = false [Sounds] - ;; {Module} {} {Implementation of ISoundModule to use.} {SoundModuleNonShared} - ;; Currently only INonSharedRegionModule module is implemented. - Module = SoundModuleNonShared + ;; {Module} {} {Implementation of ISoundModule to use.} {SoundModule} + Module = SoundModule ;; {MaxDistance} {} {Cut-off distance at which sounds will not be sent to users} {100.0} MaxDistance = 100.0 From a09cba6da363606f0e2d63118b63f5b05232c452 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 29 Oct 2012 16:17:18 +0000 Subject: [PATCH 43/55] refactoring to use assembly:classname style of configuration --- OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 5 ++++- bin/OpenSimDefaults.ini | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 1db65193f1..513a8f5385 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; +using System.IO; using System.Collections.Generic; using System.Reflection; @@ -64,7 +65,9 @@ namespace OpenSim.Region.CoreModules.World.Sound } else { - Enabled = config.GetString("Module", "SoundModule") == "SoundModule"; + Enabled = config.GetString("Module", "OpenSim.Region.CoreModules.dll:SoundModule") == + Path.GetFileName(Assembly.GetExecutingAssembly().Location) + + ":" + MethodBase.GetCurrentMethod().DeclaringType.Name; MaxDistance = config.GetFloat("MaxDistance", 100.0f); } } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 6d1af7ce1a..fa284bdef1 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1688,8 +1688,8 @@ Enabled = False AutoBackupModuleEnabled = false [Sounds] - ;; {Module} {} {Implementation of ISoundModule to use.} {SoundModule} - Module = SoundModule + ;; {Module} {} {Implementation of ISoundModule to use.} {OpenSim.Region.CoreModules.dll:SoundModule} + Module = OpenSim.Region.CoreModules.dll:SoundModule ;; {MaxDistance} {} {Cut-off distance at which sounds will not be sent to users} {100.0} MaxDistance = 100.0 From aeeed29d627f7d40bbcc160bf446a019b54e8b32 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 30 Oct 2012 01:07:14 +0000 Subject: [PATCH 44/55] correct ODEPrim.MeshAssetReveived -> MeshAssetReceived --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 2548648999..7c46ff8933 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -3335,7 +3335,6 @@ Console.WriteLine(" JointCreateFixed"); m_material = pMaterial; } - private void CheckMeshAsset() { if (_pbs.SculptEntry && !m_assetFailed && _pbs.SculptTexture != UUID.Zero) @@ -3345,12 +3344,12 @@ Console.WriteLine(" JointCreateFixed"); { RequestAssetDelegate assetProvider = _parent_scene.RequestAssetMethod; if (assetProvider != null) - assetProvider(_pbs.SculptTexture, MeshAssetReveived); + assetProvider(_pbs.SculptTexture, MeshAssetReceived); }); } } - void MeshAssetReveived(AssetBase asset) + void MeshAssetReceived(AssetBase asset) { if (asset.Data != null && asset.Data.Length > 0) { From 37de965233ad6c25c2ce7a29d89762aa478a6147 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 30 Oct 2012 01:08:00 +0000 Subject: [PATCH 45/55] Make MeshAssetReceived private. Keep methods private unless they need to be opened up to external callers. Reduces analysis complexity. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 7c46ff8933..5b49e3b036 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -3349,7 +3349,7 @@ Console.WriteLine(" JointCreateFixed"); } } - void MeshAssetReceived(AssetBase asset) + private void MeshAssetReceived(AssetBase asset) { if (asset.Data != null && asset.Data.Length > 0) { From cccf6953276eda0af34fb7b8e95c2c4351db5546 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 30 Oct 2012 01:14:48 +0000 Subject: [PATCH 46/55] Add asset != null check to ODEPrim.MeshAssetReceived instead of throwing exception. In some cases (such as failure to receive response from asset service), it is possible for a null to be returned from IAssetService.Get(string, object, AssetRetrieved). --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 5b49e3b036..26372955ff 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -3351,7 +3351,7 @@ Console.WriteLine(" JointCreateFixed"); private void MeshAssetReceived(AssetBase asset) { - if (asset.Data != null && asset.Data.Length > 0) + if (asset != null && asset.Data != null && asset.Data.Length > 0) { if (!_pbs.SculptEntry) return; From 9bc4dc6c5f7c8d1430db31a657399d0bf794a7f7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 30 Oct 2012 01:19:32 +0000 Subject: [PATCH 47/55] Add method doc to IAssetService.Get(string, object, AssetRetrieved) outlining the situations in which AssetRetrieved may be called back with a null AssetBase. These situations include asset not found and remote service not responding. --- OpenSim/Services/Interfaces/IAssetService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/Interfaces/IAssetService.cs b/OpenSim/Services/Interfaces/IAssetService.cs index 80494f177a..3c469c6f43 100644 --- a/OpenSim/Services/Interfaces/IAssetService.cs +++ b/OpenSim/Services/Interfaces/IAssetService.cs @@ -68,7 +68,11 @@ namespace OpenSim.Services.Interfaces /// /// The asset id /// Represents the requester. Passed back via the handler - /// The handler to call back once the asset has been retrieved + /// + /// The handler to call back once the asset has been retrieved. This will be called back with a null AssetBase + /// if the asset could not be found for some reason (e.g. if it does not exist, if a remote asset service + /// was not contactable, if it is not in the database, etc.). + /// /// True if the id was parseable, false otherwise bool Get(string id, Object sender, AssetRetrieved handler); From ff6c69000e3f192f81e7408a522b78d91521a5ff Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 30 Oct 2012 01:40:59 +0000 Subject: [PATCH 48/55] Log warning if mesh/sculpt asset couldn't be found by ODEPrim.MeshAssetReceived() callback. Presumably this is now more useful if the false positive from the old method of loading mesh assets have been eliminated. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 26372955ff..5a0b8d1fe1 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -3364,6 +3364,12 @@ Console.WriteLine(" JointCreateFixed"); m_taintshape = true; _parent_scene.AddPhysicsActorTaint(this); } + else + { + m_log.WarnFormat( + "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}", + _pbs.SculptTexture, Name, _position, _parent_scene.Name); + } } } } \ No newline at end of file From 984faf24dfaea26cdd436c8097abf334b74ebed8 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 30 Oct 2012 01:48:05 +0000 Subject: [PATCH 49/55] Only create a new list to check if objects have reached targets if there actually are any targets. --- OpenSim/Region/Framework/Scenes/Scene.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7d8cbf5804..69c10273c0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1692,15 +1692,19 @@ namespace OpenSim.Region.Framework.Scenes private void CheckAtTargets() { - List objs = new List(); + List objs = null; + lock (m_groupsWithTargets) { - foreach (SceneObjectGroup grp in m_groupsWithTargets.Values) - objs.Add(grp); + if (m_groupsWithTargets.Count != 0) + objs = new List(m_groupsWithTargets.Values); } - foreach (SceneObjectGroup entry in objs) - entry.checkAtTargets(); + if (objs != null) + { + foreach (SceneObjectGroup entry in objs) + entry.checkAtTargets(); + } } /// From 9e05067a4f029983a749c348259112a8a18432d1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Oct 2012 21:45:39 +0100 Subject: [PATCH 50/55] Add AnimState to CADU --- OpenSim/Framework/ChildAgentDataUpdate.cs | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 6d048f436f..dfe60aaff1 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -306,6 +306,8 @@ namespace OpenSim.Framework public AgentGroupData[] Groups; public Animation[] Anims; + public Animation DefaultAnim = null; + public Animation AnimState = null; public UUID GranterID; @@ -390,6 +392,16 @@ namespace OpenSim.Framework args["animations"] = anims; } + if (DefaultAnim != null) + { + args["default_animation"] = DefaultAnim.PackUpdateMessage(); + } + + if (AnimState != null) + { + args["animation_state"] = AnimState.PackUpdateMessage(); + } + if (Appearance != null) args["packed_appearance"] = Appearance.Pack(); @@ -583,6 +595,30 @@ namespace OpenSim.Framework } } + if (args["default_animation"] != null) + { + try + { + DefaultAnim = new Animation((OSDMap)args["default_animation"]); + } + catch + { + DefaultAnim = null; + } + } + + if (args["animation_state"] != null) + { + try + { + AnimState = new Animation((OSDMap)args["animation_state"]); + } + catch + { + AnimState = null; + } + } + //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); From fd9cb3cb68959c2dd42dd0645fef50161ac085a7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Oct 2012 23:08:22 +0000 Subject: [PATCH 51/55] Store and send the current movement animation state to a new sim on crossing --- .../Region/Framework/Scenes/Animation/AnimationSet.cs | 11 +++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 3d8e8be795..65ae445950 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -45,6 +45,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation private OpenSim.Framework.Animation m_defaultAnimation = new OpenSim.Framework.Animation(); private List m_animations = new List(); + public OpenSim.Framework.Animation DefaultAnimation + { + get { return m_defaultAnimation; } + } + public OpenSim.Framework.Animation ImplicitDefaultAnimation { get { return m_implicitDefaultAnimation; } @@ -126,6 +131,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation return false; } + // Called from serialization only + public void SetImplicitDefaultAnimation(UUID animID, int sequenceNum, UUID objectID) + { + m_implicitDefaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID); + } + protected bool ResetDefaultAnimation() { return TrySetDefaultAnimation("STAND", 1, UUID.Zero); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index aa82af41c1..71e322d432 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3075,6 +3075,8 @@ namespace OpenSim.Region.Framework.Scenes cAgent.Anims = Animator.Animations.ToArray(); } catch { } + cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; + cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(this, cAgent); @@ -3146,6 +3148,10 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? if (cAgent.Anims != null) Animator.Animations.FromArray(cAgent.Anims); + if (cAgent.DefaultAnim != null) + Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); + if (cAgent.AnimState != null) + Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); From 6235d16c3148bb6f9f881b0dc286deccfdf9148a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 31 Oct 2012 00:31:18 +0000 Subject: [PATCH 52/55] Make "show object part" command correctly display script status. Uses new IEntityInventory.TryGetScriptInstanceRunning() Makes it clearer that TaskInventoryItem.ScriptRunning cannot be used as it is temporary and not updated. --- OpenSim/Framework/TaskInventoryDictionary.cs | 4 +- OpenSim/Framework/TaskInventoryItem.cs | 19 +++---- .../Avatar/Attachments/AttachmentsModule.cs | 6 +-- .../Objects/Commands/ObjectCommandsModule.cs | 8 ++- .../Framework/Interfaces/IEntityInventory.cs | 13 +++++ .../Scenes/SceneObjectPartInventory.cs | 52 +++++++++++++------ .../ScriptEngine/XEngine/Tests/XEngineTest.cs | 10 +++- 7 files changed, 77 insertions(+), 35 deletions(-) diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 421bd5ddcf..8af2c41866 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs @@ -35,10 +35,12 @@ using OpenMetaverse; namespace OpenSim.Framework { /// - /// A dictionary for task inventory. + /// A dictionary containing task inventory items. Indexed by item UUID. /// + /// /// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before /// iterating over it. + /// public class TaskInventoryDictionary : Dictionary, ICloneable, IXmlSerializable { diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 3b40381c61..a06f8e73ef 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -73,9 +73,6 @@ namespace OpenSim.Framework private bool _ownerChanged = false; - // This used ONLY during copy. It can't be relied on at other times! - private bool _scriptRunning = true; - public UUID AssetID { get { return _assetID; @@ -353,14 +350,13 @@ namespace OpenSim.Framework } } - public bool ScriptRunning { - get { - return _scriptRunning; - } - set { - _scriptRunning = value; - } - } + /// + /// This used ONLY during copy. It can't be relied on at other times! + /// + /// + /// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now. + /// + public bool ScriptRunning { get; set; } // See ICloneable @@ -388,6 +384,7 @@ namespace OpenSim.Framework public TaskInventoryItem() { + ScriptRunning = true; CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; } } diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2a513e91d8..24170fcce0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -571,9 +571,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (grp.HasGroupChanged) { -// m_log.DebugFormat( -// "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", -// grp.UUID, grp.AttachmentPoint); + m_log.DebugFormat( + "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", + grp.UUID, grp.AttachmentPoint); string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState); diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index b2c9bce7e5..ab8f14344b 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -606,12 +606,18 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands cdt.AddColumn("Asset UUID", 36); foreach (TaskInventoryItem item in inv.GetInventoryItems()) + { + bool foundScriptInstance, scriptRunning; + foundScriptInstance + = SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, item, out scriptRunning); + cdt.AddRow( item.Name, ((InventoryType)item.InvType).ToString(), - (InventoryType)item.InvType == InventoryType.LSL ? item.ScriptRunning.ToString() : "n/a", + foundScriptInstance ? scriptRunning.ToString() : "n/a", item.ItemID.ToString(), item.AssetID.ToString()); + } return sb.Append(cdt.ToString()); } diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index c457b2f2f5..150193da5b 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -149,6 +149,19 @@ namespace OpenSim.Region.Framework.Interfaces /// void StopScriptInstance(UUID itemId); + /// + /// Try to get the script running status. + /// + /// + /// Returns true if a script for the item was found in one of the simulator's script engines. In this case, + /// the running parameter will reflect the running status. + /// Returns false if the item could not be found, if the item is not a script or if a script instance for the + /// item was not found in any of the script engines. In this case, running status is irrelevant. + /// + /// + /// + bool TryGetScriptInstanceRunning(UUID itemId, out bool running); + /// /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative /// name is chosen. diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index bdb044692b..db723fa481 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -232,31 +232,49 @@ namespace OpenSim.Region.Framework.Scenes if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) return; - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - if (engines == null) // No engine at all - return; - lock (Items) { foreach (TaskInventoryItem item in Items.Values) { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - bool running; - - if (e.HasScript(item.ItemID, out running)) - { - item.ScriptRunning = running; - break; - } - } - } + bool running; + if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) + item.ScriptRunning = running; } } } + public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) + { + running = false; + + TaskInventoryItem item = GetInventoryItem(itemId); + + if (item == null) + return false; + + return TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running); + } + + public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running) + { + running = false; + + if (item.InvType != (int)InventoryType.LSL) + return false; + + IScriptModule[] engines = scene.RequestModuleInterfaces(); + if (engines == null) // No engine at all + return false; + + foreach (IScriptModule e in engines) + { + if (e.HasScript(item.ItemID, out running)) + return true; + } + + return false; + } + public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) { int scriptsValidForStarting = 0; diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index f247a0be42..f331658662 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests // log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); -// UUID objectId = TestHelpers.ParseTail(0x2); +// UUID objectId = TestHelpers.ParseTail(0x100); // UUID itemId = TestHelpers.ParseTail(0x3); string itemName = "TestStartScript() Item"; @@ -105,12 +105,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; - m_scene.RezNewScript(userId, itemTemplate); + SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate); m_chatEvent.WaitOne(60000); Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()"); Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running")); + + bool running; + TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); + Assert.That( + SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True); + Assert.That(running, Is.True); } private void OnChatFromWorld(object sender, OSChatMessage oscm) From 4ba48151b232716ebb473bc320793a9610a96e5b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 31 Oct 2012 00:39:45 +0000 Subject: [PATCH 53/55] Handle UUIDGroupName and ObjectGroup viewer UDP requests asynchronously rather than synchronously. This is to avoid the entire scene loop being held up when the group service is slow to respond. There's no obvious reason for these queries to be sync rather than async. --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 8e5a6d2b42..7382e0935f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5219,8 +5219,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false); - AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest, false); - AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest, false); + AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest); + AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest); AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest); AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); From b3072cf343e15ec58a70295cc66996a44e30ff1d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 31 Oct 2012 00:46:07 +0000 Subject: [PATCH 54/55] Mark ScriptException as [Serializable] for when it has to cross AppDomains --- OpenSim/Region/ScriptEngine/Shared/ScriptException.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs index ae67fc5585..ebe6fbd716 100644 --- a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs +++ b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs @@ -29,6 +29,7 @@ using System; namespace OpenSim.Region.ScriptEngine.Shared { + [Serializable] public class ScriptException : Exception { public ScriptException() : base() {} From 566aaef1f4c7eade864d9e3d7b7b6ded8e0156a1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 31 Oct 2012 00:56:41 +0000 Subject: [PATCH 55/55] Also add the additional ScriptException constructor necessary to get [Serializable] to work. --- OpenSim/Region/ScriptEngine/Shared/ScriptException.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs index ebe6fbd716..f55ba7e6c5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs +++ b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs @@ -26,6 +26,7 @@ */ using System; +using System.Runtime.Serialization; namespace OpenSim.Region.ScriptEngine.Shared { @@ -37,5 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared public ScriptException(string message) : base(message) {} public ScriptException(string message, Exception innerException) : base(message, innerException) {} + + public ScriptException(SerializationInfo info, StreamingContext context) :base(info, context) {} } } \ No newline at end of file