diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 60 |
1 files changed, 57 insertions, 3 deletions
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); |