aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs7
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs60
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs1
7 files changed, 74 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index cdd6943..7836937 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -879,12 +879,13 @@ namespace OpenSim.Region.Environment.Scenes
879 SceneObjectGroup group = part.ParentGroup; 879 SceneObjectGroup group = part.ParentGroup;
880 if (group != null) 880 if (group != null)
881 { 881 {
882 int type = group.RemoveInventoryItem(localID, itemID); 882 TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
883 part.GetProperties(remoteClient); 883 if (item.Type == 10)
884 if (type == 10)
885 { 884 {
886 EventManager.TriggerRemoveScript(localID, itemID); 885 EventManager.TriggerRemoveScript(localID, itemID);
887 } 886 }
887 group.RemoveInventoryItem(localID, itemID);
888 part.GetProperties(remoteClient);
888 } 889 }
889 else 890 else
890 { 891 {
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 78c8c62..8ee2179 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1742,6 +1742,8 @@ namespace OpenSim.Region.Environment.Scenes
1742 { 1742 {
1743 //SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1743 //SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1744 1744
1745 group.RemoveScriptInstances();
1746
1745 foreach (SceneObjectPart part in group.Children.Values) 1747 foreach (SceneObjectPart part in group.Children.Values)
1746 { 1748 {
1747 if (part.PhysActor != null) 1749 if (part.PhysActor != null)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 514f6d8..5670492 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -958,7 +958,7 @@ namespace OpenSim.Region.Environment.Scenes
958 { 958 {
959 foreach (SceneObjectPart part in m_parts.Values) 959 foreach (SceneObjectPart part in m_parts.Values)
960 { 960 {
961 part.RemoveScriptInstances(); 961// part.RemoveScriptInstances();
962 962
963 List<ScenePresence> avatars = Scene.GetScenePresences(); 963 List<ScenePresence> avatars = Scene.GetScenePresences();
964 for (int i = 0; i < avatars.Count; i++) 964 for (int i = 0; i < avatars.Count; i++)
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index a05edbd..0c807a8 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -93,6 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
93 DetectParams GetDetectParams(int idx); 93 DetectParams GetDetectParams(int idx);
94 UUID GetDetectID(int idx); 94 UUID GetDetectID(int idx);
95 void SaveState(string assembly); 95 void SaveState(string assembly);
96 void DestroyScriptInstance();
96 97
97 IScriptApi GetApi(string name); 98 IScriptApi GetApi(string name);
98 } 99 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 20b52b7..2b19ae1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2553,6 +2553,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2553 2553
2554 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 2554 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
2555 { 2555 {
2556 llReleaseControls();
2557
2556 m_host.TaskInventory[invItemID].PermsGranter=UUID.Zero; 2558 m_host.TaskInventory[invItemID].PermsGranter=UUID.Zero;
2557 m_host.TaskInventory[invItemID].PermsMask=0; 2559 m_host.TaskInventory[invItemID].PermsMask=0;
2558 2560
@@ -2564,6 +2566,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2564 return; 2566 return;
2565 } 2567 }
2566 2568
2569 if ( m_host.TaskInventory[invItemID].PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
2570 llReleaseControls();
2571
2567 m_host.AddScriptLPS(1); 2572 m_host.AddScriptLPS(1);
2568 2573
2569 if (m_host.ParentGroup.RootPart.IsAttachment && agent == m_host.ParentGroup.RootPart.AttachedAvatar) 2574 if (m_host.ParentGroup.RootPart.IsAttachment && agent == m_host.ParentGroup.RootPart.AttachedAvatar)
@@ -2648,6 +2653,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2648 client.OnScriptAnswer-=handleScriptAnswer; 2653 client.OnScriptAnswer-=handleScriptAnswer;
2649 m_waitingForScriptAnswer=false; 2654 m_waitingForScriptAnswer=false;
2650 2655
2656 if((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
2657 llReleaseControls();
2658
2651 m_host.TaskInventory[invItemID].PermsMask=answer; 2659 m_host.TaskInventory[invItemID].PermsMask=answer;
2652 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 2660 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
2653 "run_time_permissions", new Object[] { 2661 "run_time_permissions", new Object[] {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index da55858..dd1bfaa 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -77,6 +77,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
77 private int m_MaxScriptQueue; 77 private int m_MaxScriptQueue;
78 private bool m_SaveState = true; 78 private bool m_SaveState = true;
79 private bool m_ShuttingDown = false; 79 private bool m_ShuttingDown = false;
80 private int m_ControlEventsInQueue = 0;
81 private int m_LastControlLevel = 0;
80 82
81 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); 83 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
82 84
@@ -320,6 +322,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
320 } 322 }
321 } 323 }
322 324
325 private void ReleaseControls()
326 {
327 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
328 if (part != null && part.TaskInventory.ContainsKey(m_ItemID))
329 {
330 UUID permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
331 int permsMask = part.TaskInventory[m_ItemID].PermsMask;
332
333 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
334 {
335
336 ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter);
337 if (presence != null)
338 presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID);
339 }
340 }
341 }
342
343 public void DestroyScriptInstance()
344 {
345 ReleaseControls();
346 }
347
323 public void RemoveState() 348 public void RemoveState()
324 { 349 {
325 string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), 350 string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly),
@@ -439,7 +464,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
439 if (m_EventQueue.Count >= m_MaxScriptQueue) 464 if (m_EventQueue.Count >= m_MaxScriptQueue)
440 return; 465 return;
441 466
442 m_EventQueue.Enqueue(data);
443 if (data.EventName == "timer") 467 if (data.EventName == "timer")
444 { 468 {
445 if (m_TimerQueued) 469 if (m_TimerQueued)
@@ -447,8 +471,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
447 m_TimerQueued = true; 471 m_TimerQueued = true;
448 } 472 }
449 473
450 if (!m_RunEvents) 474 if (data.EventName == "control")
451 return; 475 {
476 int held = ((LSL_Types.LSLInteger)data.Params[1]).value;
477 int changed= ((LSL_Types.LSLInteger)data.Params[2]).value;
478
479 // If the last message was a 0 (nothing held)
480 // and this one is also nothing held, drop it
481 //
482 if (m_LastControlLevel == held && held == 0)
483 return;
484
485 // If there is one or more queued, then queue
486 // only changed ones, else queue unconditionally
487 //
488 if (m_ControlEventsInQueue > 0)
489 {
490 if (m_LastControlLevel == held)
491 return;
492 }
493
494 m_LastControlLevel = held;
495 m_ControlEventsInQueue++;
496 }
497
498 m_EventQueue.Enqueue(data);
452 499
453 if (m_CurrentResult == null) 500 if (m_CurrentResult == null)
454 { 501 {
@@ -475,6 +522,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
475 } 522 }
476 if (data.EventName == "timer") 523 if (data.EventName == "timer")
477 m_TimerQueued = false; 524 m_TimerQueued = false;
525 if (data.EventName == "control")
526 {
527 if (m_ControlEventsInQueue > 0)
528 m_ControlEventsInQueue--;
529 }
478 } 530 }
479 531
480 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); 532 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
@@ -616,6 +668,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
616 bool running = Running; 668 bool running = Running;
617 669
618 RemoveState(); 670 RemoveState();
671 ReleaseControls();
619 672
620 Stop(0); 673 Stop(0);
621 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); 674 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
@@ -641,6 +694,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
641 // bool running = Running; 694 // bool running = Running;
642 695
643 RemoveState(); 696 RemoveState();
697 ReleaseControls();
644 698
645 m_Script.ResetVars(); 699 m_Script.ResetVars();
646 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); 700 SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 3b48362..466a879 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -565,6 +565,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
565 } 565 }
566 566
567 instance.RemoveState(); 567 instance.RemoveState();
568 instance.DestroyScriptInstance();
568 569
569 instance = null; 570 instance = null;
570 571