From 36ee0e8fb9309d33b5003f936e8935a3c368b7e0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 16 Dec 2008 04:12:40 +0000 Subject: Fix script controls for weapons --- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 4668dae..c0779f2 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -45,7 +45,7 @@ using OSD = OpenMetaverse.StructuredData.OSD; namespace OpenSim.Region.Environment.Scenes { - enum ScriptControlled : int + enum ScriptControlled : uint { CONTROL_ZERO = 0, CONTROL_FWD = 1, @@ -85,6 +85,7 @@ namespace OpenSim.Region.Environment.Scenes private Dictionary scriptedcontrols = new Dictionary(); private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; + private bool MouseDown = false; private SceneObjectGroup proxyObjectGroup = null; //private SceneObjectPart proxyObjectPart = null; @@ -3341,6 +3342,27 @@ namespace OpenSim.Region.Environment.Scenes ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; + if (MouseDown) + { + 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) { @@ -3374,15 +3396,6 @@ namespace OpenSim.Region.Environment.Scenes { allflags |= ScriptControlled.CONTROL_ROT_LEFT; } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_ML_LBUTTON; - } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) - { - allflags |= ScriptControlled.CONTROL_LBUTTON; - } - // 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) { -- cgit v1.1