From 86669a1664310d16da0cbb8f3a8e034464f16d3a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 7 May 2008 19:41:03 +0000 Subject: [PATCH] * Other then the prim update experiments that are going on now, llTakeControls works now along with the 'release controls button'. llReleaseControls() works mostly :D. --- OpenSim/Framework/IClientAPI.cs | 4 ++++ .../ClientStack/LindenUDP/LLClientView.cs | 12 +++++++++++ .../Region/Environment/Scenes/SceneEvents.cs | 13 ++++++++++-- .../Environment/Scenes/ScenePresence.cs | 20 +++++++++++++++++-- .../Examples/SimpleModule/MyNpcCharacter.cs | 2 ++ .../Common/ScriptEngineBase/EventManager.cs | 1 + 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 7dbddff82b..8344196402 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -530,6 +530,8 @@ namespace OpenSim.Framework public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); public delegate void RequestPayPrice(IClientAPI remoteClient, LLUUID objectID); + + public delegate void ForceReleaseControls(IClientAPI remoteClient, LLUUID agentID); //Estate Requests public delegate void DetailedEstateDataRequest(IClientAPI remoteClient, LLUUID invoice); @@ -702,6 +704,8 @@ namespace OpenSim.Framework event AgentSit OnUndo; + event ForceReleaseControls OnForceReleaseControls; + event DetailedEstateDataRequest OnDetailedEstateDataRequest; event SetEstateFlagsRequest OnSetEstateFlagsRequest; event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 28f8364a9c..8078491366 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -240,6 +240,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private ObjectDeselect handlerObjectDetach = null; private AgentSit handlerOnUndo = null; + private ForceReleaseControls handlerForceReleaseControls = null; + /* Properties */ public LLUUID SecureSessionId @@ -802,6 +804,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event RequestPayPrice OnRequestPayPrice; public event AgentSit OnUndo; + public event ForceReleaseControls OnForceReleaseControls; + public event DetailedEstateDataRequest OnDetailedEstateDataRequest; public event SetEstateFlagsRequest OnSetEstateFlagsRequest; public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; @@ -4004,6 +4008,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; + case PacketType.ForceScriptControlRelease: + handlerForceReleaseControls = OnForceReleaseControls; + if (handlerForceReleaseControls != null) + { + handlerForceReleaseControls(this, AgentId); + } + break; + #endregion #region Objects/m_sceneObjects diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index d409f4e368..65dca95ebb 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -137,6 +137,10 @@ namespace OpenSim.Region.Environment.Scenes public event ScriptChangedEvent OnScriptChangedEvent; + public delegate void ScriptControlEvent(uint localID, LLUUID item, LLUUID avatarID, uint held, uint changed); + + public event ScriptControlEvent OnScriptControlEvent; + public delegate void ScriptAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos); public event ScriptAtTargetEvent OnScriptAtTargetEvent; @@ -274,6 +278,7 @@ namespace OpenSim.Region.Environment.Scenes private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps; private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null; private RequestChangeWaterHeight handlerRequestChangeWaterHeight = null; //OnRequestChangeWaterHeight + private ScriptControlEvent handlerScriptControlEvent = null; private LandBuy handlerLandBuy = null; private LandBuy handlerValidateLandBuy = null; @@ -603,9 +608,13 @@ namespace OpenSim.Region.Environment.Scenes } } - internal void TriggerControlEvent(uint p, LLUUID scriptUUID, uint p_3, uint p_4) + internal void TriggerControlEvent(uint p, LLUUID scriptUUID, LLUUID avatarID, uint held, uint _changed) { - throw new Exception("The method or operation is not implemented."); + handlerScriptControlEvent = OnScriptControlEvent; + if (handlerScriptControlEvent != null) + { + handlerScriptControlEvent(p, scriptUUID, avatarID, held, _changed); + } } } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index fdafd7fd80..9343ad3cb8 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -443,6 +443,7 @@ namespace OpenSim.Region.Environment.Scenes m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; m_controllingClient.OnStartAnim += HandleStartAnim; m_controllingClient.OnStopAnim += HandleStopAnim; + m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); @@ -2491,6 +2492,15 @@ namespace OpenSim.Region.Environment.Scenes } + public void HandleForceReleaseControls(IClientAPI remoteClient, LLUUID agentID) + { + IgnoredControls = ScriptControlled.CONTROL_ZERO; + lock (scriptedcontrols) + { + scriptedcontrols.Clear(); + } + ControllingClient.SendTakeControls(int.MaxValue, false, false); + } public void UnRegisterControlEventsToScript(uint Obj_localID, LLUUID Script_item_LLUUID) { @@ -2512,6 +2522,7 @@ namespace OpenSim.Region.Environment.Scenes { ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; + if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) { allflags |= ScriptControlled.CONTROL_FWD; @@ -2552,6 +2563,7 @@ namespace OpenSim.Region.Environment.Scenes { allflags |= ScriptControlled.CONTROL_LBUTTON; } + ScriptControlled held = ScriptControlled.CONTROL_ZERO; ScriptControlled change = ScriptControlled.CONTROL_ZERO; @@ -2584,12 +2596,16 @@ namespace OpenSim.Region.Environment.Scenes { ScriptControllers scriptControlData = scriptedcontrols[scriptUUID]; ScriptControlled localHeld = held & scriptControlData.eventControls; + //if (localHeld != ScriptControlled.CONTROL_ZERO) + //{ + //int i = 1; + //} ScriptControlled localChange = change & scriptControlData.eventControls; - m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, (uint)localHeld, (uint)localChange); + m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange); } } LastCommands = allflags; - //foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags))) + } internal uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) { diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 010e65b0a9..51bc0d83a6 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -172,6 +172,8 @@ namespace OpenSim.Region.Examples.SimpleModule public event RequestPayPrice OnRequestPayPrice; public event AgentSit OnUndo; + public event ForceReleaseControls OnForceReleaseControls; + public event DetailedEstateDataRequest OnDetailedEstateDataRequest; public event SetEstateFlagsRequest OnSetEstateFlagsRequest; public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index f8f38a17fe..ecf2a4578a 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -72,6 +72,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; + myScriptEngine.World.EventManager.OnScriptControlEvent += control; // TODO: HOOK ALL EVENTS UP TO SERVER! IMoneyModule money=myScriptEngine.World.RequestModuleInterface();