Yengine: we also need to cancel timer events in queue, because some bad scripts that do work on X

This commit is contained in:
UbitUmarov
2019-11-11 12:51:09 +00:00
parent 38a77a8bb5
commit e87dfd48bf
5 changed files with 50 additions and 2 deletions

View File

@@ -237,6 +237,37 @@ namespace OpenSim.Region.ScriptEngine.Yengine
}
}
public void CancelEvent(string eventName)
{
ScriptEventCode evc;
try
{
evc = (ScriptEventCode)Enum.Parse(typeof(ScriptEventCode), eventName);
}
catch
{
return;
}
lock (m_QueueLock)
{
if(m_EventQueue.Count == 0)
return;
LinkedListNode<EventParams> lln2 = null;
for (lln2 = m_EventQueue.First; lln2 != null; lln2 = lln2.Next)
{
EventParams evt2 = lln2.Value;
if(evt2.EventName.Equals(eventName))
{
m_EventQueue.Remove(lln2);
if (evc >= 0 && m_EventCounts[(int)evc] > 0)
m_EventCounts[(int)evc]--;
}
}
}
}
// This is called in the script thread to step script until it calls
// CheckRun(). It returns what the instance's next state should be,
// ONSLEEPQ, ONYIELDQ, SUSPENDED or FINISHED.