fix release controls on deattach

This commit is contained in:
UbitUmarov
2020-02-20 08:27:42 +00:00
parent d7671f3c01
commit 7c977f9e27
4 changed files with 99 additions and 7 deletions

View File

@@ -714,6 +714,77 @@ namespace OpenSim.Region.Framework.Scenes
// m_part.ParentGroup.AddActiveScriptCount(-1);
}
public void RemoveScriptsPermissions(int permissions)
{
bool removeControl = ((permissions & 4) != 0); //takecontrol
List<UUID> grants = new List<UUID>();
List<UUID> items = new List<UUID>();
permissions = ~permissions;
m_items.LockItemsForWrite(true);
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType != (int)InventoryType.LSL)
continue;
int curmask = item.PermsMask;
UUID curGrant = item.PermsGranter;
if (removeControl && ((curmask & 4) != 0))
{
grants.Add(curGrant);
items.Add(item.ItemID);
}
curmask &= permissions;
item.PermsMask = curmask;
if(curmask == 0)
item.PermsGranter = UUID.Zero;
}
m_items.LockItemsForWrite(false);
if(grants.Count > 0)
{
for(int i = 0; i< grants.Count;++i)
{
ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(grants[i]);
if (presence != null && !presence.IsDeleted)
presence.UnRegisterControlEventsToScript(m_part.LocalId, items[i]);
}
}
}
public void RemoveScriptsPermissions(ScenePresence sp, int permissions)
{
bool removeControl = ((permissions & 4) != 0); //takecontrol
UUID grant = sp.UUID;
List<UUID> items = new List<UUID>();
permissions = ~permissions;
m_items.LockItemsForWrite(true);
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType != (int) InventoryType.LSL)
continue;
if(grant != item.PermsGranter)
continue;
int curmask = item.PermsMask;
if (removeControl && ((curmask & 4) != 0))
items.Add(item.ItemID);
curmask &= permissions;
item.PermsMask = curmask;
if(curmask == 0)
item.PermsGranter = UUID.Zero;
}
m_items.LockItemsForWrite(false);
if(items.Count > 0)
{
for(int i = 0; i < items.Count; ++i)
{
if (!sp.IsDeleted)
sp.UnRegisterControlEventsToScript(m_part.LocalId, items[i]);
}
}
}
/// <summary>
/// Check if the inventory holds an item with a given name.
/// </summary>