aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorBob Shaffer II2015-02-18 15:01:13 +0100
committerJustin Clark-Casey (justincc)2015-03-12 00:01:30 +0000
commitb4b13510e88e705e2e6fdb4b58b55bb4d234b234 (patch)
treec0015381be75df1bffb4a8b43f4b61cfccd83461 /OpenSim/Region/ScriptEngine/Shared
parentMake SmartThreadPool build pick up Properties/AssemblyInfo.cs by setting buil... (diff)
downloadopensim-SC-b4b13510e88e705e2e6fdb4b58b55bb4d234b234.zip
opensim-SC-b4b13510e88e705e2e6fdb4b58b55bb4d234b234.tar.gz
opensim-SC-b4b13510e88e705e2e6fdb4b58b55bb4d234b234.tar.bz2
opensim-SC-b4b13510e88e705e2e6fdb4b58b55bb4d234b234.tar.xz
A workaround for the state change problem described best here http://opensimulator.org/mantis/view.php?id=6960 which should make state changes behave more like is described here http://wiki.secondlife.com/wiki/State
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs23
1 files changed, 22 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 081ba03..7c7b831 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
82 private int m_ControlEventsInQueue; 82 private int m_ControlEventsInQueue;
83 private int m_LastControlLevel; 83 private int m_LastControlLevel;
84 private bool m_CollisionInQueue; 84 private bool m_CollisionInQueue;
85 private bool m_StateChangeInProgress;
85 86
86 // The following is for setting a minimum delay between events 87 // The following is for setting a minimum delay between events
87 private double m_minEventDelay; 88 private double m_minEventDelay;
@@ -210,6 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
210 public void ClearQueue() 211 public void ClearQueue()
211 { 212 {
212 m_TimerQueued = false; 213 m_TimerQueued = false;
214 m_StateChangeInProgress = false;
213 EventQueue.Clear(); 215 EventQueue.Clear();
214 } 216 }
215 217
@@ -616,13 +618,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
616 { 618 {
617 if (state == State) 619 if (state == State)
618 return; 620 return;
619 621
622 // Remove all queued events, remembering the last timer event
623 EventParams lastTimerEv = null;
624 while (EventQueue.Count > 0)
625 {
626 EventParams tempv = (EventParams)EventQueue.Dequeue();
627 if (tempv.EventName == "timer") lastTimerEv = tempv;
628 }
629 // Post events
620 PostEvent(new EventParams("state_exit", new Object[0], 630 PostEvent(new EventParams("state_exit", new Object[0],
621 new DetectParams[0])); 631 new DetectParams[0]));
622 PostEvent(new EventParams("state", new Object[] { state }, 632 PostEvent(new EventParams("state", new Object[] { state },
623 new DetectParams[0])); 633 new DetectParams[0]));
624 PostEvent(new EventParams("state_entry", new Object[0], 634 PostEvent(new EventParams("state_entry", new Object[0],
625 new DetectParams[0])); 635 new DetectParams[0]));
636 // Requeue the timer event after the state changing events
637 if (lastTimerEv != null) EventQueue.Enqueue(lastTimerEv);
638 // This will stop events from being queued and processed
639 // until the new state is started
640 m_StateChangeInProgress = true;
626 641
627 throw new EventAbortException(); 642 throw new EventAbortException();
628 } 643 }
@@ -697,6 +712,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
697 712
698 m_CollisionInQueue = true; 713 m_CollisionInQueue = true;
699 } 714 }
715
716 // The only events that persist across state changes are timers
717 if (m_StateChangeInProgress && data.EventName != "timer") return;
700 718
701 EventQueue.Enqueue(data); 719 EventQueue.Enqueue(data);
702 720
@@ -785,6 +803,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
785 803
786 AsyncCommandManager.StateChange(Engine, 804 AsyncCommandManager.StateChange(Engine,
787 LocalID, ItemID); 805 LocalID, ItemID);
806 // we are effectively in the new state now, so we can resume queueing
807 // and processing other non-timer events
808 m_StateChangeInProgress = false;
788 809
789 Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); 810 Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State));
790 } 811 }