aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCharles Krinke2008-08-13 14:52:14 +0000
committerCharles Krinke2008-08-13 14:52:14 +0000
commit3278ab83970a7d377a9ce5e00f85be31c70505ec (patch)
tree231a3be0121f6d3d7932ee6532208619e0b7c78e
parentAdd a Find(Predicate) method to the cache to look for items by data (diff)
downloadopensim-SC-3278ab83970a7d377a9ce5e00f85be31c70505ec.zip
opensim-SC-3278ab83970a7d377a9ce5e00f85be31c70505ec.tar.gz
opensim-SC-3278ab83970a7d377a9ce5e00f85be31c70505ec.tar.bz2
opensim-SC-3278ab83970a7d377a9ce5e00f85be31c70505ec.tar.xz
Mantis#1856. Thank you kindly, HomerHorwitz for a patch that:
Fixes this Mantis bug with llTakeControls() & ControllingClient() API.
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs60
1 files changed, 20 insertions, 40 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 342fd03..636d08c 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -872,7 +872,7 @@ namespace OpenSim.Region.Environment.Scenes
872 { 872 {
873 if (scriptedcontrols.Count > 0) 873 if (scriptedcontrols.Count > 0)
874 { 874 {
875 SendControlToScripts(flags, LastCommands); 875 SendControlToScripts(flags);
876 flags = this.RemoveIgnoredControls(flags, IgnoredControls); 876 flags = this.RemoveIgnoredControls(flags, IgnoredControls);
877 877
878 } 878 }
@@ -2741,11 +2741,12 @@ namespace OpenSim.Region.Environment.Scenes
2741 } 2741 }
2742 } 2742 }
2743 2743
2744 internal void SendControlToScripts(uint flags, ScriptControlled lastFlags) 2744 internal void SendControlToScripts(uint flags)
2745 { 2745 {
2746 2746
2747 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 2747 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
2748 2748
2749 // find all activated controls, whether the scripts are interested in them or not
2749 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 2750 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
2750 { 2751 {
2751 allflags |= ScriptControlled.CONTROL_FWD; 2752 allflags |= ScriptControlled.CONTROL_FWD;
@@ -2770,11 +2771,11 @@ namespace OpenSim.Region.Environment.Scenes
2770 { 2771 {
2771 allflags |= ScriptControlled.CONTROL_RIGHT; 2772 allflags |= ScriptControlled.CONTROL_RIGHT;
2772 } 2773 }
2773 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) 2774 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
2774 { 2775 {
2775 allflags |= ScriptControlled.CONTROL_ROT_RIGHT; 2776 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
2776 } 2777 }
2777 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) 2778 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
2778 { 2779 {
2779 allflags |= ScriptControlled.CONTROL_ROT_LEFT; 2780 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
2780 } 2781 }
@@ -2787,45 +2788,24 @@ namespace OpenSim.Region.Environment.Scenes
2787 allflags |= ScriptControlled.CONTROL_LBUTTON; 2788 allflags |= ScriptControlled.CONTROL_LBUTTON;
2788 } 2789 }
2789 2790
2790 ScriptControlled held = ScriptControlled.CONTROL_ZERO; 2791 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
2791 ScriptControlled change = ScriptControlled.CONTROL_ZERO; 2792 if(allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) {
2792 2793 lock (scriptedcontrols)
2793 foreach (ScriptControlled DCF in Enum.GetValues(typeof (ScriptControlled)))
2794 {
2795 // Held
2796 if ((lastFlags & DCF) != 0 && (allflags & DCF) != 0)
2797 { 2794 {
2798 held |= DCF; 2795 foreach (LLUUID scriptUUID in scriptedcontrols.Keys)
2799 continue; 2796 {
2800 } 2797 ScriptControllers scriptControlData = scriptedcontrols[scriptUUID];
2801 // Not held recently 2798 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
2802 if ((lastFlags & DCF) != 0 && (allflags & DCF) == 0) 2799 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
2803 { 2800 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
2804 change |= DCF; 2801 if(localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) {
2805 continue; 2802 // only send if still pressed or just changed
2806 } 2803 m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange);
2807 // Newly pressed. 2804 }
2808 if ((lastFlags & DCF) == 0 && (allflags & DCF) != 0) 2805 }
2809 {
2810 change |= DCF;
2811 continue;
2812 }
2813 }
2814
2815 lock (scriptedcontrols)
2816 {
2817 foreach (LLUUID scriptUUID in scriptedcontrols.Keys)
2818 {
2819 ScriptControllers scriptControlData = scriptedcontrols[scriptUUID];
2820 ScriptControlled localHeld = held & scriptControlData.eventControls;
2821 //if (localHeld != ScriptControlled.CONTROL_ZERO)
2822 //{
2823 //int i = 1;
2824 //}
2825 ScriptControlled localChange = change & scriptControlData.eventControls;
2826 m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange);
2827 } 2806 }
2828 } 2807 }
2808
2829 LastCommands = allflags; 2809 LastCommands = allflags;
2830 } 2810 }
2831 2811