aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs125
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs11
4 files changed, 153 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index f7d6f9e..58d9e90 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1595,6 +1595,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1595 OutPacket(remove, ThrottleOutPacketType.Asset); 1595 OutPacket(remove, ThrottleOutPacketType.Asset);
1596 } 1596 }
1597 1597
1598 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
1599 {
1600 ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
1601 ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
1602 ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
1603 ddata.Controls = (uint)controls;
1604 ddata.PassToAgent = passToAgent;
1605 ddata.TakeControls = TakeControls;
1606 data[0] = ddata;
1607 scriptcontrol.Data = data;
1608 OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
1609 }
1610
1598 public void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) 1611 public void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName)
1599 { 1612 {
1600 ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory); 1613 ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index aefecd0..2e6fe3d 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -40,6 +40,29 @@ using OpenSim.Region.Physics.Manager;
40 40
41namespace OpenSim.Region.Environment.Scenes 41namespace OpenSim.Region.Environment.Scenes
42{ 42{
43 enum ScriptControlled : int
44 {
45 CONTROL_ZERO = 0,
46 CONTROL_FWD = 1,
47 CONTROL_BACK = 2,
48 CONTROL_LEFT = 4,
49 CONTROL_RIGHT = 8,
50 CONTROL_UP = 16,
51 CONTROL_DOWN = 32,
52 CONTROL_ROT_LEFT = 256,
53 CONTROL_ROT_RIGHT = 512,
54 CONTROL_LBUTTON = 268435456,
55 CONTROL_ML_LBUTTON = 1073741824
56 }
57
58 struct ScriptControllers
59 {
60 public LLUUID itemID;
61 public uint objID;
62 public ScriptControlled ignoreControls;
63 public ScriptControlled eventControls;
64 }
65
43 [Serializable] 66 [Serializable]
44 public class ScenePresence : EntityBase, ISerializable 67 public class ScenePresence : EntityBase, ISerializable
45 { 68 {
@@ -56,6 +79,9 @@ namespace OpenSim.Region.Environment.Scenes
56 public LLUUID currentParcelUUID = LLUUID.Zero; 79 public LLUUID currentParcelUUID = LLUUID.Zero;
57 private List<LLUUID> m_animations = new List<LLUUID>(); 80 private List<LLUUID> m_animations = new List<LLUUID>();
58 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>();
83 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
84
59 public Vector3 lastKnownAllowedPosition = new Vector3(); 85 public Vector3 lastKnownAllowedPosition = new Vector3();
60 public bool sentMessageAboutRestrictedParcelFlyingDown = false; 86 public bool sentMessageAboutRestrictedParcelFlyingDown = false;
61 87
@@ -787,6 +813,17 @@ namespace OpenSim.Region.Environment.Scenes
787 // m_AgentControlFlags = flags; 813 // m_AgentControlFlags = flags;
788 // m_headrotation = agentData.AgentData.HeadRotation; 814 // m_headrotation = agentData.AgentData.HeadRotation;
789 // m_state = agentData.AgentData.State; 815 // m_state = agentData.AgentData.State;
816
817
818 lock (scriptedcontrols)
819 {
820 if (scriptedcontrols.Count > 0)
821 {
822 flags = this.RemoveIgnoredControls(flags, IgnoredControls);
823
824 }
825 }
826
790 827
791 if (m_allowMovement) 828 if (m_allowMovement)
792 { 829 {
@@ -2397,5 +2434,93 @@ namespace OpenSim.Region.Environment.Scenes
2397 PhysicsActor.AddForce(impulse,true); 2434 PhysicsActor.AddForce(impulse,true);
2398 } 2435 }
2399 } 2436 }
2437
2438 public void SendMovementEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, LLUUID Script_item_LLUUID)
2439 {
2440
2441 ScriptControllers obj = new ScriptControllers();
2442 obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
2443 obj.eventControls = ScriptControlled.CONTROL_ZERO;
2444
2445 obj.itemID = Script_item_LLUUID;
2446 obj.objID = Obj_localID;
2447 if (pass_on == 0 && accept == 0)
2448 {
2449 IgnoredControls |= (ScriptControlled)controls;
2450 obj.ignoreControls = (ScriptControlled)controls;
2451 }
2452
2453 if (pass_on == 0 && accept == 1)
2454 {
2455 IgnoredControls |= (ScriptControlled)controls;
2456 obj.ignoreControls = (ScriptControlled)controls;
2457 obj.eventControls = (ScriptControlled)controls;
2458 }
2459 if (pass_on == 1 && accept == 1)
2460 {
2461 IgnoredControls = ScriptControlled.CONTROL_ZERO;
2462 obj.eventControls = (ScriptControlled)controls;
2463 obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
2464 }
2465
2466 lock (scriptedcontrols)
2467 {
2468 if (pass_on == 1 && accept == 0)
2469 {
2470 IgnoredControls &= ~(ScriptControlled)controls;
2471 if (scriptedcontrols.ContainsKey(Script_item_LLUUID))
2472 scriptedcontrols.Remove(Script_item_LLUUID);
2473
2474 }
2475 else
2476 {
2477
2478 if (scriptedcontrols.ContainsKey(Script_item_LLUUID))
2479 {
2480 scriptedcontrols[Script_item_LLUUID] = obj;
2481 }
2482 else
2483 {
2484 scriptedcontrols.Add(Script_item_LLUUID, obj);
2485 }
2486 }
2487 }
2488 ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
2489
2490
2491 }
2492 internal uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored)
2493 {
2494 if (Ignored == ScriptControlled.CONTROL_ZERO)
2495 return flags;
2496 if ((Ignored & ScriptControlled.CONTROL_BACK) != 0)
2497 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
2498 if ((Ignored & ScriptControlled.CONTROL_FWD) != 0)
2499 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS);
2500 if ((Ignored & ScriptControlled.CONTROL_DOWN) != 0)
2501 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG);
2502 if ((Ignored & ScriptControlled.CONTROL_UP) != 0)
2503 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS);
2504 if ((Ignored & ScriptControlled.CONTROL_LEFT) != 0)
2505 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
2506 if ((Ignored & ScriptControlled.CONTROL_RIGHT) != 0)
2507 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG);
2508 if ((Ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0)
2509 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG);
2510 if ((Ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0)
2511 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS);
2512 if ((Ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0)
2513 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN);
2514 if ((Ignored & ScriptControlled.CONTROL_LBUTTON) != 0)
2515 flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN);
2516 //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
2517 //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
2518 //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS,
2519 //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
2520 //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
2521 //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
2522 //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
2523 return flags;
2524 }
2400 } 2525 }
2401} 2526}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 79bc7d0..4929675 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -444,6 +444,10 @@ namespace OpenSim.Region.Examples.SimpleModule
444 { 444 {
445 } 445 }
446 446
447 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
448 {
449 }
450
447 public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) 451 public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName)
448 { 452 {
449 } 453 }
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 54c26d9..59afe32 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -1936,6 +1936,17 @@ 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[InventorySelf()].PermsGranter != LLUUID.Zero)
1940 {
1941
1942 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)
1944 {
1945 presence.SendMovementEventsToScript(controls, accept, pass_on, m_localID, m_itemID);
1946
1947 }
1948 }
1949
1939 m_host.AddScriptLPS(1); 1950 m_host.AddScriptLPS(1);
1940 NotImplemented("llTakeControls"); 1951 NotImplemented("llTakeControls");
1941 } 1952 }