more on scripts *target* events

master
UbitUmarov 2020-02-26 19:18:07 +00:00
parent 94f88e330b
commit ad5aff2d17
5 changed files with 37 additions and 21 deletions

View File

@ -3011,20 +3011,24 @@ namespace OpenSim.Region.Framework.Scenes
public void RemoveScriptEvents(UUID scriptid)
{
if (ParentGroup != null)
ParentGroup.RemoveScriptTargets(scriptid);
lock (m_scriptEvents)
{
if (m_scriptEvents.TryGetValue(scriptid, out scriptEvents ev))
{
if((ev & (scriptEvents.anyTarget)) != 0 && ParentGroup != null)
ParentGroup.RemoveScriptTargets(scriptid);
m_scriptEvents.Remove(scriptid);
aggregateScriptEvents();
}
}
}
public void RemoveScriptTargets(UUID scriptid)
{
if(ParentGroup != null)
ParentGroup.RemoveScriptTargets(scriptid);
}
/// <summary>
/// Reset UUIDs for this part. This involves generate this part's own UUID and
/// generating new UUIDs for all the items in the inventory.
@ -4001,10 +4005,6 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE OBJECT PART]: Set script events for script with id {0} on {1}/{2} to {3} in {4}",
// scriptid, Name, ParentGroup.Name, events, ParentGroup.Scene.Name);
// scriptEvents oldparts;
if (ParentGroup != null)
ParentGroup.RemoveScriptTargets(scriptid);
lock (m_scriptEvents)
{
if (m_scriptEvents.TryGetValue(scriptid, out scriptEvents ev))

View File

@ -876,6 +876,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
// and processing other non-timer events
m_StateChangeInProgress = false;
Part.RemoveScriptTargets(ItemID);
Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State));
}
else
@ -1072,8 +1073,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
ReleaseControlsorPermissions(true);
Stop(timeout);
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
part.CollisionSound = UUID.Zero;
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
m_TimerQueued = false;
@ -1084,7 +1083,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
StartParam = 0;
State = "default";
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
if (part == null)
return;
part.CollisionSound = UUID.Zero;
part.RemoveScriptTargets(ItemID);
part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State));
if (running)
Start();
@ -1103,9 +1107,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
RemoveState();
ReleaseControlsorPermissions(true);
m_Script.ResetVars();
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
part.CollisionSound = UUID.Zero;
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
m_TimerQueued = false;
@ -1116,8 +1117,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
StartParam = 0;
State = "default";
part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State));
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
if(part != null)
{
part.CollisionSound = UUID.Zero;
part.RemoveScriptTargets(ItemID);
part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State));
}
if (m_CurrentEvent != "state_entry" || oldState != "default")
{
m_SaveState = StatePersistedHere;

View File

@ -594,7 +594,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
m_XMRLSLApi.acm.TimerPlugin.CreateFromData(m_LocalID, m_ItemID, UUID.Zero, timers);
// Tell whoever cares which event handlers the new state has.
// Tell whoever cares which event handlers the new state has.
m_Part.RemoveScriptTargets(m_ItemID);
m_Part.SetScriptEvents(m_ItemID, GetStateEventFlags(stateCode));
// keep link messages

View File

@ -66,8 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// up. This makes sure we decrement m_CompiledScriptRefCount.
~XMRInstance()
{
if(!m_disposed)
Dispose();
Dispose(false);
}
/**
@ -76,11 +75,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine
*/
public void Dispose()
{
// Tell script stop executing next time it calls CheckRun().
Dispose(true);
//GC.SuppressFinalize(this);
}
public void Dispose(bool fromdispose)
{
if (m_disposed)
return;
// Tell script stop executing next time it calls CheckRun().
suspendOnCheckRunHold = true;
// Don't send us any more events.
lock(m_RunLock)
// Don't send us any more events.
lock (m_RunLock)
{
if(m_Part != null)
{

View File

@ -904,6 +904,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// 'state_entry()' event handler.
m_RunOnePhase = "ResetLocked: posting default:state_entry() event";
stateCode = 0;
m_Part.RemoveScriptTargets(m_ItemID);
m_Part.SetScriptEvents(m_ItemID, GetStateEventFlags(0));
PostEvent(new EventParams("state_entry",
zeroObjectArray,