From fe8e835bfc027696979ff0fb3135e5b2718af9ed Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sat, 28 Apr 2012 17:42:49 +0300 Subject: Fixed: scripted controls didn't work if the avatar was sitting down This fixes a bug introduced in 6473674bbf6ce006512083902e8ff1796d8c8b22 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 64fe7a8..3cf7b2a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1336,6 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor actor = PhysicsActor; if (actor == null) { + SafeSendControlsToScripts(flagsForScripts); return; } @@ -1512,20 +1513,25 @@ namespace OpenSim.Region.Framework.Scenes if (update_movementflag && ParentID == 0) Animator.UpdateMovementAnimations(); - lock (scriptedcontrols) - { - if (scriptedcontrols.Count > 0) - { - // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script - // (e.g., a walking script) checks which animation is active it will be the correct animation. - SendControlToScripts(flagsForScripts); - } - } + SafeSendControlsToScripts(flagsForScripts); } m_scene.EventManager.TriggerOnClientMovement(this); } + private void SafeSendControlsToScripts(uint flagsForScripts) + { + lock (scriptedcontrols) + { + if (scriptedcontrols.Count > 0) + { + // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script + // (e.g., a walking script) checks which animation is active it will be the correct animation. + SendControlToScripts(flagsForScripts); + } + } + } + /// /// Calculate an update to move the presence to the set target. /// -- cgit v1.1 From d0598c63f38f560ba0daf8ddf71b6218363ac887 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 30 Apr 2012 17:33:08 +0100 Subject: refactor: Simplify by combining SafeSendControlsToScripts() from fe8e835 into SendControlsToScripts() (instead of SendControlToScripts()). --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 148 ++++++++++++----------- 1 file changed, 75 insertions(+), 73 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3cf7b2a..f1d0926 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1336,7 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor actor = PhysicsActor; if (actor == null) { - SafeSendControlsToScripts(flagsForScripts); + SendControlsToScripts(flagsForScripts); return; } @@ -1513,25 +1513,12 @@ namespace OpenSim.Region.Framework.Scenes if (update_movementflag && ParentID == 0) Animator.UpdateMovementAnimations(); - SafeSendControlsToScripts(flagsForScripts); + SendControlsToScripts(flagsForScripts); } m_scene.EventManager.TriggerOnClientMovement(this); } - private void SafeSendControlsToScripts(uint flagsForScripts) - { - lock (scriptedcontrols) - { - if (scriptedcontrols.Count > 0) - { - // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script - // (e.g., a walking script) checks which animation is active it will be the correct animation. - SendControlToScripts(flagsForScripts); - } - } - } - /// /// Calculate an update to move the presence to the set target. /// @@ -3687,77 +3674,92 @@ namespace OpenSim.Region.Framework.Scenes } } - internal void SendControlToScripts(uint flags) + private void SendControlsToScripts(uint flags) { - ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; - - if (MouseDown) + // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script + // (e.g., a walking script) checks which animation is active it will be the correct animation. + lock (scriptedcontrols) { - allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) + if (scriptedcontrols.Count <= 0) + return; + + ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; + + if (MouseDown) { - allflags = ScriptControlled.CONTROL_ZERO; + allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) + { + allflags = ScriptControlled.CONTROL_ZERO; + MouseDown = true; + } + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) + { + allflags |= ScriptControlled.CONTROL_ML_LBUTTON; MouseDown = true; } - } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) + { + allflags |= ScriptControlled.CONTROL_LBUTTON; + MouseDown = true; + } + + // find all activated controls, whether the scripts are interested in them or not + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_FWD; + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_BACK; + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_UP; + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_DOWN; + } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_ML_LBUTTON; - MouseDown = true; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_LBUTTON; - MouseDown = true; - } + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_LEFT; + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_RIGHT; + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) + { + allflags |= ScriptControlled.CONTROL_ROT_RIGHT; + } + + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) + { + allflags |= ScriptControlled.CONTROL_ROT_LEFT; + } - // find all activated controls, whether the scripts are interested in them or not - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_FWD; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_BACK; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_UP; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_DOWN; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_LEFT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_RIGHT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) - { - allflags |= ScriptControlled.CONTROL_ROT_RIGHT; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) - { - allflags |= ScriptControlled.CONTROL_ROT_LEFT; - } - // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that - if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) - { - lock (scriptedcontrols) + // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that + if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) { foreach (KeyValuePair kvp in scriptedcontrols) { UUID scriptUUID = kvp.Key; ScriptControllers scriptControlData = kvp.Value; - + ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle ScriptControlled localChange = localHeld ^ localLast; // the changed bits + if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) { // only send if still pressed or just changed @@ -3765,9 +3767,9 @@ namespace OpenSim.Region.Framework.Scenes } } } + + LastCommands = allflags; } - - LastCommands = allflags; } internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) -- cgit v1.1 From 9c2a73b61ef1e834c77f5d945ebae435b033ca38 Mon Sep 17 00:00:00 2001 From: TBG Renfold Date: Tue, 24 Apr 2012 19:38:37 +0100 Subject: llGenerateKey implementation. Creates a random UUID I.E: UUID.Random().ToString(); Signed-off-by: TBG Renfold --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 +++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 +++++ 3 files changed, 13 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d641958..62b5c0f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1734,6 +1734,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rgb.y = texcolor.G; rgb.z = texcolor.B; return rgb; + } else { @@ -3192,6 +3193,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return m_host.UUID.ToString(); } + public LSL_Key llGenerateKey() + { + m_host.AddScriptLPS(1); + return UUID.Random().ToString(); + } + public void llSetBuoyancy(double buoyancy) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 69df392..7a797ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -105,6 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Integer llFloor(double f); void llForceMouselook(int mouselook); LSL_Float llFrand(double mag); + LSL_Key llGenerateKey(); LSL_Vector llGetAccel(); LSL_Integer llGetAgentInfo(string id); LSL_String llGetAgentLanguage(string id); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 3c2f7bd..80fa530 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -369,6 +369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llFrand(mag); } + public LSL_Key llGenerateKey() + { + return m_LSL_Functions.llGenerateKey(); + } + public LSL_Vector llGetAccel() { return m_LSL_Functions.llGetAccel(); -- cgit v1.1 From b678ea18b238ef1ab816445f48bd1c838f9978fc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 30 Apr 2012 18:44:22 +0100 Subject: Create TestHelpers.EnableLogging() and DisableLogging() to turn logging on and off within tests. This makes *.Tests.dll.config files no longer needed, hence deleted. --- OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | 4 +--- OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | 6 ++++++ OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index ab6311b..4a21dc9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; using NUnit.Framework; using OpenMetaverse; @@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests Vector3 position = new Vector3(200,200,21); foreach (Border b in testborders) - { Assert.That(!b.TestCross(position)); - } - position = new Vector3(200,280,21); Assert.That(NorthBorder.TestCross(position)); diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 1c33a5f..d23c965 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs @@ -26,7 +26,9 @@ */ using System; +using System.IO; using System.Reflection; +using System.Text; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; @@ -44,6 +46,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests public void TestDuplicateObject() { TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + Scene scene = new SceneHelpers().SetupScene(); UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); @@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(dupePart1.PhysActor, Is.Not.Null); Assert.That(dupePart2.PhysActor, Is.Not.Null); */ + +// TestHelpers.DisableLogging(); } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 19542ff..c750cc5 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -38,7 +38,8 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; -using System.Threading; +using System.IO; +using System.Text; namespace OpenSim.Region.Framework.Scenes.Tests { -- cgit v1.1