aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs5
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs104
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs2
5 files changed, 143 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 2feed78..d409f4e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -602,5 +602,10 @@ namespace OpenSim.Region.Environment.Scenes
602 handlerAvatarKill(KillerObjectLocalID, DeadAvatar); 602 handlerAvatarKill(KillerObjectLocalID, DeadAvatar);
603 } 603 }
604 } 604 }
605
606 internal void TriggerControlEvent(uint p, LLUUID scriptUUID, uint p_3, uint p_4)
607 {
608 throw new Exception("The method or operation is not implemented.");
609 }
605 } 610 }
606} 611}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 66363b7..fdafd7f 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -81,6 +81,7 @@ namespace OpenSim.Region.Environment.Scenes
81 private List<int> m_animationSeqs = new List<int>(); 81 private List<int> m_animationSeqs = new List<int>();
82 private Dictionary<LLUUID, ScriptControllers> scriptedcontrols = new Dictionary<LLUUID, ScriptControllers>(); 82 private Dictionary<LLUUID, ScriptControllers> scriptedcontrols = new Dictionary<LLUUID, ScriptControllers>();
83 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; 83 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
84 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
84 85
85 public Vector3 lastKnownAllowedPosition = new Vector3(); 86 public Vector3 lastKnownAllowedPosition = new Vector3();
86 public bool sentMessageAboutRestrictedParcelFlyingDown = false; 87 public bool sentMessageAboutRestrictedParcelFlyingDown = false;
@@ -819,6 +820,7 @@ namespace OpenSim.Region.Environment.Scenes
819 { 820 {
820 if (scriptedcontrols.Count > 0) 821 if (scriptedcontrols.Count > 0)
821 { 822 {
823 SendControlToScripts(flags, LastCommands);
822 flags = this.RemoveIgnoredControls(flags, IgnoredControls); 824 flags = this.RemoveIgnoredControls(flags, IgnoredControls);
823 825
824 } 826 }
@@ -2435,7 +2437,7 @@ namespace OpenSim.Region.Environment.Scenes
2435 } 2437 }
2436 } 2438 }
2437 2439
2438 public void SendMovementEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, LLUUID Script_item_LLUUID) 2440 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, LLUUID Script_item_LLUUID)
2439 { 2441 {
2440 2442
2441 ScriptControllers obj = new ScriptControllers(); 2443 ScriptControllers obj = new ScriptControllers();
@@ -2489,6 +2491,106 @@ namespace OpenSim.Region.Environment.Scenes
2489 2491
2490 2492
2491 } 2493 }
2494
2495 public void UnRegisterControlEventsToScript(uint Obj_localID, LLUUID Script_item_LLUUID)
2496 {
2497 lock (scriptedcontrols)
2498 {
2499 if (scriptedcontrols.ContainsKey(Script_item_LLUUID))
2500 {
2501 scriptedcontrols.Remove(Script_item_LLUUID);
2502 IgnoredControls = ScriptControlled.CONTROL_ZERO;
2503 foreach (ScriptControllers scData in scriptedcontrols.Values)
2504 {
2505 IgnoredControls |= scData.ignoreControls;
2506 }
2507 }
2508 }
2509 }
2510
2511 internal void SendControlToScripts(uint flags, ScriptControlled lastFlags)
2512 {
2513
2514 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
2515 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
2516 {
2517 allflags |= ScriptControlled.CONTROL_FWD;
2518 }
2519 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
2520 {
2521 allflags |= ScriptControlled.CONTROL_BACK;
2522 }
2523 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
2524 {
2525 allflags |= ScriptControlled.CONTROL_UP;
2526 }
2527 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
2528 {
2529 allflags |= ScriptControlled.CONTROL_DOWN;
2530 }
2531 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
2532 {
2533 allflags |= ScriptControlled.CONTROL_LEFT;
2534 }
2535 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
2536 {
2537 allflags |= ScriptControlled.CONTROL_RIGHT;
2538 }
2539 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
2540 {
2541 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
2542 }
2543 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
2544 {
2545 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
2546 }
2547 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
2548 {
2549 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
2550 }
2551 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
2552 {
2553 allflags |= ScriptControlled.CONTROL_LBUTTON;
2554 }
2555 ScriptControlled held = ScriptControlled.CONTROL_ZERO;
2556 ScriptControlled change = ScriptControlled.CONTROL_ZERO;
2557
2558 foreach (ScriptControlled DCF in Enum.GetValues(typeof (ScriptControlled)))
2559 {
2560 // Held
2561 if ((lastFlags & DCF) != 0 && (allflags & DCF) != 0)
2562 {
2563 held |= DCF;
2564 continue;
2565 }
2566 // Not held recently
2567 if ((lastFlags & DCF) != 0 && (allflags & DCF) == 0)
2568 {
2569 change |= DCF;
2570 continue;
2571 }
2572 // Newly pressed.
2573 if ((lastFlags & DCF) == 0 && (allflags & DCF) != 0)
2574 {
2575 change |= DCF;
2576 continue;
2577 }
2578
2579 }
2580
2581 lock (scriptedcontrols)
2582 {
2583 foreach (LLUUID scriptUUID in scriptedcontrols.Keys)
2584 {
2585 ScriptControllers scriptControlData = scriptedcontrols[scriptUUID];
2586 ScriptControlled localHeld = held & scriptControlData.eventControls;
2587 ScriptControlled localChange = change & scriptControlData.eventControls;
2588 m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, (uint)localHeld, (uint)localChange);
2589 }
2590 }
2591 LastCommands = allflags;
2592 //foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags)))
2593 }
2492 internal uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) 2594 internal uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored)
2493 { 2595 {
2494 if (Ignored == ScriptControlled.CONTROL_ZERO) 2596 if (Ignored == ScriptControlled.CONTROL_ZERO)
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index e8e4f80..1f23d00 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -1936,25 +1936,53 @@ namespace OpenSim.Region.ScriptEngine.Common
1936 1936
1937 public void llTakeControls(int controls, int accept, int pass_on) 1937 public void llTakeControls(int controls, int accept, int pass_on)
1938 { 1938 {
1939 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
1940 {
1941 return;
1942 }
1943
1939 if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero) 1944 if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero)
1940 { 1945 {
1941 1946
1942 ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[InventorySelf()].PermsGranter]; 1947 ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[InventorySelf()].PermsGranter];
1943 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0) 1948 if (presence != null)
1944 { 1949 {
1945 presence.SendMovementEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 1950 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0)
1951 {
1952 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID);
1946 1953
1954 }
1947 } 1955 }
1948 } 1956 }
1949 1957
1950 m_host.AddScriptLPS(1); 1958 m_host.AddScriptLPS(1);
1951 NotImplemented("llTakeControls"); 1959 //NotImplemented("llTakeControls");
1952 } 1960 }
1953 1961
1954 public void llReleaseControls() 1962 public void llReleaseControls()
1955 { 1963 {
1956 m_host.AddScriptLPS(1); 1964 m_host.AddScriptLPS(1);
1957 NotImplemented("llReleaseControls"); 1965
1966 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
1967 {
1968 return;
1969 }
1970
1971 if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero)
1972 {
1973
1974 ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[InventorySelf()].PermsGranter];
1975 if (presence != null)
1976 {
1977 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0)
1978 {
1979 // Unregister controls from Presence
1980 presence.UnRegisterControlEventsToScript(m_localID, m_itemID);
1981 // Remove Take Control permission.
1982 m_host.TaskInventory[InventorySelf()].PermsMask &= ~BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS;
1983 }
1984 }
1985 }
1958 } 1986 }
1959 1987
1960 public void llAttachToAvatar(int attachment) 1988 public void llAttachToAvatar(int attachment)
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index 77a4048..f8f38a1 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -225,9 +225,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
225 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor", EventQueueManager.llDetectNull); 225 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor", EventQueueManager.llDetectNull);
226 } 226 }
227 227
228 public void control(uint localID, LLUUID itemID) 228 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change)
229 { 229 {
230 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull); 230 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(held), new LSL_Types.LSLInteger(change)});
231 } 231 }
232 232
233 public void email(uint localID, LLUUID itemID) 233 public void email(uint localID, LLUUID itemID)
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index 1edd3bd..be42539 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.ScriptEngine.Common
54 void on_rez(uint localID, LLUUID itemID); 54 void on_rez(uint localID, LLUUID itemID);
55 void sensor(uint localID, LLUUID itemID); 55 void sensor(uint localID, LLUUID itemID);
56 void no_sensor(uint localID, LLUUID itemID); 56 void no_sensor(uint localID, LLUUID itemID);
57 void control(uint localID, LLUUID itemID); 57 void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change);
58 void money(uint LocalID, LLUUID agentID, int amount); 58 void money(uint LocalID, LLUUID agentID, int amount);
59 void email(uint localID, LLUUID itemID); 59 void email(uint localID, LLUUID itemID);
60 void at_target(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos); 60 void at_target(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos);