diff options
author | Melanie Thielker | 2008-09-17 22:00:56 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-17 22:00:56 +0000 |
commit | 7e8320bada32b642058487b84af2c8355fc18292 (patch) | |
tree | e52c44d7189d9689b0d621af3f73d2b70f268703 /OpenSim/Region/ScriptEngine | |
parent | Adding currentLookAt to useragents table in SQLite. This complements the (diff) | |
download | opensim-SC_OLD-7e8320bada32b642058487b84af2c8355fc18292.zip opensim-SC_OLD-7e8320bada32b642058487b84af2c8355fc18292.tar.gz opensim-SC_OLD-7e8320bada32b642058487b84af2c8355fc18292.tar.bz2 opensim-SC_OLD-7e8320bada32b642058487b84af2c8355fc18292.tar.xz |
Kan-Ed fix series. Fix llTakeControls to behave as documented.
XEngine fixes: prevent queue overruns, prevent spamming when no key
is down. Release controls when conflicting permissions are requested
or permissions are refused later. Release when prim or script are deleted.
Fixes Scene script instance deletion semantics.
Diffstat (limited to '')
4 files changed, 67 insertions, 3 deletions
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 | ||