a few changes to script engines releasecontrols
parent
8d8b5b756f
commit
d7671f3c01
|
@ -459,23 +459,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReleaseControls()
|
private void ReleaseControlsorPermissions(bool fullpermissions)
|
||||||
{
|
{
|
||||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||||
|
|
||||||
if (part != null)
|
if (part != null && part.TaskInventory != null)
|
||||||
{
|
{
|
||||||
int permsMask;
|
int permsMask;
|
||||||
UUID permsGranter;
|
UUID permsGranter;
|
||||||
part.TaskInventory.LockItemsForRead(true);
|
part.TaskInventory.LockItemsForWrite(true);
|
||||||
if (!part.TaskInventory.ContainsKey(ItemID))
|
if (!part.TaskInventory.TryGetValue(ItemID, out TaskInventoryItem item))
|
||||||
{
|
{
|
||||||
part.TaskInventory.LockItemsForRead(false);
|
part.TaskInventory.LockItemsForWrite(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
permsGranter = part.TaskInventory[ItemID].PermsGranter;
|
permsGranter = item.PermsGranter;
|
||||||
permsMask = part.TaskInventory[ItemID].PermsMask;
|
permsMask = item.PermsMask;
|
||||||
part.TaskInventory.LockItemsForRead(false);
|
if(fullpermissions)
|
||||||
|
{
|
||||||
|
item.PermsGranter = UUID.Zero;
|
||||||
|
item.PermsMask = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
item.PermsMask = permsMask & ~(ScriptBaseClass.PERMISSION_TAKE_CONTROLS | ScriptBaseClass.PERMISSION_CONTROL_CAMERA);
|
||||||
|
part.TaskInventory.LockItemsForWrite(false);
|
||||||
|
|
||||||
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||||
{
|
{
|
||||||
|
@ -488,7 +495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
|
|
||||||
public void DestroyScriptInstance()
|
public void DestroyScriptInstance()
|
||||||
{
|
{
|
||||||
ReleaseControls();
|
ReleaseControlsorPermissions(false);
|
||||||
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
||||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||||
if (part != null)
|
if (part != null)
|
||||||
|
@ -1062,12 +1069,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
bool running = Running;
|
bool running = Running;
|
||||||
|
|
||||||
RemoveState();
|
RemoveState();
|
||||||
ReleaseControls();
|
ReleaseControlsorPermissions(true);
|
||||||
|
|
||||||
Stop(timeout);
|
Stop(timeout);
|
||||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||||
part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
|
|
||||||
part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
|
|
||||||
part.CollisionSound = UUID.Zero;
|
part.CollisionSound = UUID.Zero;
|
||||||
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
||||||
|
|
||||||
|
@ -1097,12 +1102,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
// bool running = Running;
|
// bool running = Running;
|
||||||
|
|
||||||
RemoveState();
|
RemoveState();
|
||||||
ReleaseControls();
|
ReleaseControlsorPermissions(true);
|
||||||
|
|
||||||
m_Script.ResetVars();
|
m_Script.ResetVars();
|
||||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||||
part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
|
|
||||||
part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
|
|
||||||
part.CollisionSound = UUID.Zero;
|
part.CollisionSound = UUID.Zero;
|
||||||
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
||||||
|
|
||||||
|
@ -1114,8 +1117,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
StartParam = 0;
|
StartParam = 0;
|
||||||
State = "default";
|
State = "default";
|
||||||
|
|
||||||
part.SetScriptEvents(ItemID,
|
part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State));
|
||||||
(int)m_Script.GetStateEventFlags(State));
|
|
||||||
|
|
||||||
if (m_CurrentEvent != "state_entry" || oldState != "default")
|
if (m_CurrentEvent != "state_entry" || oldState != "default")
|
||||||
{
|
{
|
||||||
|
|
|
@ -871,11 +871,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||||
private void ResetLocked(string from)
|
private void ResetLocked(string from)
|
||||||
{
|
{
|
||||||
m_RunOnePhase = "ResetLocked: releasing controls";
|
m_RunOnePhase = "ResetLocked: releasing controls";
|
||||||
ReleaseControls();
|
ReleaseControlsOrPermissions(true);
|
||||||
|
m_Part.CollisionSound = UUID.Zero;
|
||||||
|
|
||||||
m_RunOnePhase = "ResetLocked: removing script";
|
m_RunOnePhase = "ResetLocked: removing script";
|
||||||
m_Part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0;
|
|
||||||
m_Part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
|
|
||||||
IUrlModule urlModule = m_Engine.World.RequestModuleInterface<IUrlModule>();
|
IUrlModule urlModule = m_Engine.World.RequestModuleInterface<IUrlModule>();
|
||||||
if(urlModule != null)
|
if(urlModule != null)
|
||||||
urlModule.ScriptRemoved(m_ItemID);
|
urlModule.ScriptRemoved(m_ItemID);
|
||||||
|
@ -916,31 +915,33 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||||
m_RunOnePhase = "ResetLocked: reset complete";
|
m_RunOnePhase = "ResetLocked: reset complete";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReleaseControls()
|
private void ReleaseControlsOrPermissions(bool fullPermissions)
|
||||||
{
|
{
|
||||||
if(m_Part != null)
|
if(m_Part != null && m_Part.TaskInventory != null)
|
||||||
{
|
{
|
||||||
bool found;
|
|
||||||
int permsMask;
|
int permsMask;
|
||||||
UUID permsGranter;
|
UUID permsGranter;
|
||||||
|
m_Part.TaskInventory.LockItemsForWrite(true);
|
||||||
try
|
if (!m_Part.TaskInventory.TryGetValue(m_ItemID, out TaskInventoryItem item))
|
||||||
{
|
{
|
||||||
permsGranter = m_Part.TaskInventory[m_ItemID].PermsGranter;
|
m_Part.TaskInventory.LockItemsForWrite(false);
|
||||||
permsMask = m_Part.TaskInventory[m_ItemID].PermsMask;
|
return;
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
catch
|
permsGranter = item.PermsGranter;
|
||||||
|
permsMask = item.PermsMask;
|
||||||
|
if(fullPermissions)
|
||||||
{
|
{
|
||||||
permsGranter = UUID.Zero;
|
item.PermsGranter = UUID.Zero;
|
||||||
permsMask = 0;
|
item.PermsMask = 0;
|
||||||
found = false;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
item.PermsMask = permsMask & ~(ScriptBaseClass.PERMISSION_TAKE_CONTROLS | ScriptBaseClass.PERMISSION_CONTROL_CAMERA);
|
||||||
|
m_Part.TaskInventory.LockItemsForWrite(false);
|
||||||
|
|
||||||
if(found && ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0))
|
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||||
{
|
{
|
||||||
ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter);
|
ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter);
|
||||||
if(presence != null)
|
if (presence != null)
|
||||||
presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID);
|
presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue