* Consistently lock part.TaskInventory as pointed out in http://opensimulator.org/mantis/view.php?id=3159
* Not locking causes enumeration exceptions as described in this matis * part.TaskInventory needs to be locked for every access as it's a dictionary * Extra locking will hopefully not cause any major issues - in places where the enumeration of the dictionary performs other lock or long running operations, the dictionary is cloned insteadGenericGridServerConcept
parent
c28b2f799a
commit
01f70de2ea
|
@ -36,9 +36,9 @@ namespace OpenSim.Framework
|
|||
{
|
||||
/// <summary>
|
||||
/// A dictionary for task inventory.
|
||||
///
|
||||
/// This class is not thread safe. Callers must synchronize on Dictionary methods.
|
||||
/// </summary>
|
||||
/// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before
|
||||
/// iterating over it.
|
||||
public class TaskInventoryDictionary : Dictionary<UUID, TaskInventoryItem>,
|
||||
ICloneable, IXmlSerializable
|
||||
{
|
||||
|
|
|
@ -202,6 +202,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
// Fix ownership/creator of inventory items
|
||||
// Not doing so results in inventory items
|
||||
// being no copy/no mod for everyone
|
||||
lock (part.TaskInventory)
|
||||
{
|
||||
TaskInventoryDictionary inv = part.TaskInventory;
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
|
||||
{
|
||||
|
@ -215,6 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
|
||||
{
|
||||
|
|
|
@ -226,11 +226,14 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
|||
{
|
||||
TaskInventoryDictionary tinv = sog.RootPart.TaskInventory;
|
||||
|
||||
lock (tinv)
|
||||
{
|
||||
foreach (TaskInventoryItem titem in tinv.Values)
|
||||
{
|
||||
uuids.Add(titem.AssetID, (InventoryType)titem.Type == InventoryType.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<UUID, bool> SniffUUIDs(AssetBase asset)
|
||||
{
|
||||
|
|
|
@ -1713,10 +1713,13 @@ if (m_shape != null) {
|
|||
|
||||
Dictionary<Guid, TaskInventoryItem> TaskInventory_work = new Dictionary<Guid, TaskInventoryItem>();
|
||||
|
||||
lock (TaskInventory)
|
||||
{
|
||||
foreach (UUID id in TaskInventory.Keys)
|
||||
{
|
||||
TaskInventory_work.Add(id.Guid, TaskInventory[id]);
|
||||
}
|
||||
}
|
||||
|
||||
info.AddValue("TaskInventory", TaskInventory_work);
|
||||
|
||||
|
@ -2166,8 +2169,10 @@ if (m_shape != null) {
|
|||
{
|
||||
//Trys to fetch sound id from prim's inventory.
|
||||
//Prim's inventory doesn't support non script items yet
|
||||
SceneObjectPart op = this;
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in op.TaskInventory)
|
||||
|
||||
lock (TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
|
||||
{
|
||||
if (item.Value.Name == sound)
|
||||
{
|
||||
|
@ -2176,6 +2181,7 @@ if (m_shape != null) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
|
||||
foreach (ScenePresence p in avatarts)
|
||||
|
@ -2486,8 +2492,9 @@ if (m_shape != null) {
|
|||
if (!UUID.TryParse(sound, out soundID))
|
||||
{
|
||||
// search sound file from inventory
|
||||
SceneObjectPart op = this;
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in op.TaskInventory)
|
||||
lock (TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
|
||||
{
|
||||
if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
|
||||
{
|
||||
|
@ -2496,6 +2503,7 @@ if (m_shape != null) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (soundID == UUID.Zero)
|
||||
return;
|
||||
|
|
|
@ -141,8 +141,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (part.Shape.SculptTexture != UUID.Zero)
|
||||
assetUuids[part.Shape.SculptTexture] = 1;
|
||||
|
||||
TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
|
||||
|
||||
// Now analyze this prim's inventory items to preserve all the uuids that they reference
|
||||
foreach (TaskInventoryItem tii in part.TaskInventory.Values)
|
||||
foreach (TaskInventoryItem tii in taskDictionary.Values)
|
||||
{
|
||||
//m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type);
|
||||
|
||||
|
|
|
@ -250,6 +250,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
UUID invItemID = new UUID();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
|
||||
|
@ -258,6 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return invItemID;
|
||||
}
|
||||
|
@ -265,6 +268,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
private UUID InventoryKey(string name, int type)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == name)
|
||||
|
@ -275,12 +281,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return inv.Value.AssetID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
private UUID InventoryKey(string name)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == name)
|
||||
|
@ -288,6 +299,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return inv.Value.AssetID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
|
@ -2376,16 +2389,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
TaskInventoryItem item = m_host.TaskInventory[invItemID];
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
item = m_host.TaskInventory[invItemID];
|
||||
}
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return 0;
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
|
||||
{
|
||||
LSLError("No permissions to give money");
|
||||
return 0;
|
||||
}
|
||||
|
||||
UUID toID=new UUID();
|
||||
UUID toID = new UUID();
|
||||
|
||||
if (!UUID.TryParse(destination, out toID))
|
||||
{
|
||||
|
@ -2393,7 +2413,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return 0;
|
||||
}
|
||||
|
||||
IMoneyModule money=World.RequestModuleInterface<IMoneyModule>();
|
||||
IMoneyModule money = World.RequestModuleInterface<IMoneyModule>();
|
||||
|
||||
if (money == null)
|
||||
{
|
||||
|
@ -2401,7 +2421,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool result=money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount);
|
||||
bool result
|
||||
= money.ObjectGiveMoney(
|
||||
m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount);
|
||||
|
||||
if (result)
|
||||
return 1;
|
||||
|
@ -2448,7 +2470,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (dist > m_ScriptDistanceFactor * 10.0f)
|
||||
return;
|
||||
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
|
||||
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
|
||||
{
|
||||
if (inv.Value.Name == inventory)
|
||||
{
|
||||
|
@ -2500,6 +2524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
llSay(0, "Could not find object " + inventory);
|
||||
}
|
||||
|
||||
|
@ -2571,18 +2596,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
public void llTakeControls(int controls, int accept, int pass_on)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
if (m_host.TaskInventory[InventorySelf()].PermsGranter != UUID.Zero)
|
||||
if (item.PermsGranter != UUID.Zero)
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter);
|
||||
ScenePresence presence = World.GetScenePresence(item.PermsGranter);
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
if ((m_host.TaskInventory[InventorySelf()].PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
{
|
||||
presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID);
|
||||
}
|
||||
|
@ -2594,25 +2624,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
public void llReleaseControls()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
TaskInventoryItem item;
|
||||
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
if (m_host.TaskInventory[InventorySelf()].PermsGranter != UUID.Zero)
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (item.PermsGranter != UUID.Zero)
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter);
|
||||
ScenePresence presence = World.GetScenePresence(item.PermsGranter);
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
if ((m_host.TaskInventory[InventorySelf()].PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
{
|
||||
// Unregister controls from Presence
|
||||
presence.UnRegisterControlEventsToScript(m_localID, m_itemID);
|
||||
// Remove Take Control permission.
|
||||
m_host.TaskInventory[InventorySelf()].PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
|
||||
item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2838,16 +2873,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
UUID invItemID=InventorySelf();
|
||||
UUID invItemID = InventorySelf();
|
||||
if (invItemID == UUID.Zero)
|
||||
return;
|
||||
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return;
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
|
||||
{
|
||||
ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
|
||||
ScenePresence presence = World.GetScenePresence(item.PermsGranter);
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
|
@ -2869,10 +2914,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (invItemID == UUID.Zero)
|
||||
return;
|
||||
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
|
||||
return;
|
||||
else
|
||||
item = m_host.TaskInventory[InventorySelf()];
|
||||
}
|
||||
|
||||
if (item.PermsGranter == UUID.Zero)
|
||||
return;
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
|
||||
{
|
||||
UUID animID = new UUID();
|
||||
|
||||
|
@ -2881,7 +2936,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
animID=InventoryKey(anim);
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
|
||||
ScenePresence presence = World.GetScenePresence(item.PermsGranter);
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
|
@ -2929,22 +2984,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
public void llRequestPermissions(string agent, int perm)
|
||||
{
|
||||
UUID agentID=new UUID();
|
||||
UUID agentID = new UUID();
|
||||
|
||||
if (!UUID.TryParse(agent, out agentID))
|
||||
return;
|
||||
|
||||
UUID invItemID=InventorySelf();
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
if (invItemID == UUID.Zero)
|
||||
return; // Not in a prim? How??
|
||||
|
||||
TaskInventoryItem item;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
item = m_host.TaskInventory[invItemID];
|
||||
}
|
||||
|
||||
if (agentID == UUID.Zero || perm == 0) // Releasing permissions
|
||||
{
|
||||
llReleaseControls();
|
||||
|
||||
m_host.TaskInventory[invItemID].PermsGranter=UUID.Zero;
|
||||
m_host.TaskInventory[invItemID].PermsMask=0;
|
||||
item.PermsGranter = UUID.Zero;
|
||||
item.PermsMask = 0;
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
"run_time_permissions", new Object[] {
|
||||
|
@ -2954,7 +3016,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return;
|
||||
}
|
||||
|
||||
if ( m_host.TaskInventory[invItemID].PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
|
||||
if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
|
||||
llReleaseControls();
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
@ -2969,8 +3031,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter=agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask=perm;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask = perm;
|
||||
}
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
"run_time_permissions", new Object[] {
|
||||
|
@ -2990,8 +3055,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter=agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask=perm;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask = perm;
|
||||
}
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
"run_time_permissions", new Object[] {
|
||||
|
@ -3006,19 +3074,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
if (presence != null)
|
||||
{
|
||||
string ownerName=resolveName(m_host.ParentGroup.RootPart.OwnerID);
|
||||
string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID);
|
||||
if (ownerName == String.Empty)
|
||||
ownerName="(hippos)";
|
||||
ownerName = "(hippos)";
|
||||
|
||||
if (!m_waitingForScriptAnswer)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter=agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask=0;
|
||||
presence.ControllingClient.OnScriptAnswer+=handleScriptAnswer;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsGranter = agentID;
|
||||
m_host.TaskInventory[invItemID].PermsMask = 0;
|
||||
}
|
||||
|
||||
presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
|
||||
m_waitingForScriptAnswer=true;
|
||||
}
|
||||
|
||||
presence.ControllingClient.SendScriptQuestion(m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm);
|
||||
presence.ControllingClient.SendScriptQuestion(
|
||||
m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3034,7 +3108,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (taskID != m_host.UUID)
|
||||
return;
|
||||
|
||||
UUID invItemID=InventorySelf();
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
if (invItemID == UUID.Zero)
|
||||
return;
|
||||
|
@ -3045,7 +3119,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
|
||||
llReleaseControls();
|
||||
|
||||
m_host.TaskInventory[invItemID].PermsMask=answer;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
m_host.TaskInventory[invItemID].PermsMask = answer;
|
||||
}
|
||||
|
||||
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
|
||||
"run_time_permissions", new Object[] {
|
||||
new LSL_Integer(answer) },
|
||||
|
@ -3056,6 +3134,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
|
@ -3063,6 +3143,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return item.PermsGranter.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero.ToString();
|
||||
}
|
||||
|
@ -3071,6 +3152,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
|
@ -3081,6 +3164,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return perms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3111,7 +3195,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID = InventorySelf();
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
|
||||
|
||||
TaskInventoryItem item;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
item = m_host.TaskInventory[invItemID];
|
||||
}
|
||||
|
||||
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
|
||||
&& !m_automaticLinkPermission)
|
||||
{
|
||||
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
|
||||
|
@ -3119,7 +3210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
|
||||
IClientAPI client = null;
|
||||
ScenePresence sp = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
|
||||
ScenePresence sp = World.GetScenePresence(item.PermsGranter);
|
||||
if (sp != null)
|
||||
client = sp.ControllingClient;
|
||||
|
||||
|
@ -3162,18 +3253,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
|
||||
&& !m_automaticLinkPermission)
|
||||
{
|
||||
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (linknum < ScriptBaseClass.LINK_THIS)
|
||||
return;
|
||||
|
||||
SceneObjectGroup parentPrim = m_host.ParentGroup;
|
||||
|
||||
if (parentPrim.RootPart.AttachmentPoint != 0)
|
||||
return; // Fail silently if attached
|
||||
SceneObjectPart childPrim = null;
|
||||
|
||||
switch (linknum)
|
||||
{
|
||||
case ScriptBaseClass.LINK_ROOT:
|
||||
|
@ -3236,8 +3335,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
SceneObjectGroup parentPrim = m_host.ParentGroup;
|
||||
if (parentPrim.RootPart.AttachmentPoint != 0)
|
||||
return; // Fail silently if attached
|
||||
|
||||
List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
|
||||
parts.Remove(parentPrim.RootPart);
|
||||
|
||||
foreach (SceneObjectPart part in parts)
|
||||
{
|
||||
parentPrim.DelinkFromGroup(part.LocalId, true);
|
||||
|
@ -3330,6 +3431,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
int count = 0;
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Type == type || type == -1)
|
||||
|
@ -3337,6 +3441,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
count = count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -3344,6 +3450,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
ArrayList keys = new ArrayList();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Type == type || type == -1)
|
||||
|
@ -3351,6 +3460,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
keys.Add(inv.Value.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keys.Count == 0)
|
||||
{
|
||||
return String.Empty;
|
||||
|
@ -3386,6 +3497,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
|
||||
// move the first object found with this inventory name
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == inventory)
|
||||
|
@ -3397,6 +3510,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
|
@ -3443,6 +3557,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public void llRemoveInventory(string name)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Name == name)
|
||||
|
@ -3452,6 +3569,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void llSetText(string text, LSL_Vector color, double alpha)
|
||||
{
|
||||
|
@ -3536,7 +3654,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
|
||||
|
||||
foreach (TaskInventoryItem item in itemDictionary.Values)
|
||||
{
|
||||
if (item.Type == 3 && item.Name == name)
|
||||
{
|
||||
|
@ -3622,6 +3742,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
// TODO: Parameter check logic required.
|
||||
UUID soundId = UUID.Zero;
|
||||
if (!UUID.TryParse(impact_sound, out soundId))
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
|
@ -3632,6 +3754,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_host.CollisionSound = soundId;
|
||||
m_host.CollisionSoundVolume = (float)impact_volume;
|
||||
}
|
||||
|
@ -3675,7 +3798,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
UUID partItemID;
|
||||
foreach (SceneObjectPart part in parts)
|
||||
{
|
||||
foreach (TaskInventoryItem item in part.TaskInventory.Values)
|
||||
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
|
||||
|
||||
foreach (TaskInventoryItem item in itemsDictionary.Values)
|
||||
{
|
||||
if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT)
|
||||
{
|
||||
|
@ -3684,7 +3809,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (m_host.ParentGroup.Children.Count == 1)
|
||||
linkNumber = 0;
|
||||
|
||||
|
||||
object[] resobj = new object[]
|
||||
{
|
||||
new LSL_Integer(linkNumber), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
|
||||
|
@ -3875,11 +3999,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
public LSL_String llGetScriptName()
|
||||
{
|
||||
|
||||
string result = String.Empty;
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.ItemID == m_itemID)
|
||||
|
@ -3888,9 +4013,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
// this function to understand which shape it is (taken from meshmerizer)
|
||||
|
@ -4142,6 +4267,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_String llGetInventoryKey(string name)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == name)
|
||||
|
@ -4156,6 +4284,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero.ToString();
|
||||
}
|
||||
|
||||
|
@ -5539,12 +5669,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
|
||||
private UUID GetTaskInventoryItem(string name)
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == name)
|
||||
return inv.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
|
@ -5853,6 +5987,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
|
||||
// copy the first script found with this inventory name
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == name)
|
||||
|
@ -5866,6 +6002,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
|
@ -7614,6 +7751,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Integer llGetInventoryPermMask(string item, int mask)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == item)
|
||||
|
@ -7633,6 +7773,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -7645,6 +7787,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_String llGetInventoryCreator(string item)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == item)
|
||||
|
@ -7652,7 +7797,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return inv.Value.CreatorID.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
llSay(0, "No item name '" + item + "'");
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
|
@ -8143,6 +8291,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Integer llGetInventoryType(string name)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == name)
|
||||
|
@ -8150,6 +8301,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return inv.Value.Type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -8174,16 +8327,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Vector llGetCameraPos()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID=InventorySelf();
|
||||
UUID invItemID = InventorySelf();
|
||||
|
||||
if (invItemID == UUID.Zero)
|
||||
return new LSL_Vector();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
return new LSL_Vector();
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
|
||||
{
|
||||
ShoutError("No permissions to track the camera");
|
||||
return new LSL_Vector();
|
||||
}
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
|
||||
if (presence != null)
|
||||
{
|
||||
|
@ -8196,21 +8356,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Rotation llGetCameraRot()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
UUID invItemID=InventorySelf();
|
||||
UUID invItemID = InventorySelf();
|
||||
if (invItemID == UUID.Zero)
|
||||
return new LSL_Rotation();
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
|
||||
return new LSL_Rotation();
|
||||
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
|
||||
{
|
||||
ShoutError("No permissions to track the camera");
|
||||
return new LSL_Rotation();
|
||||
}
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
|
||||
if (presence != null)
|
||||
{
|
||||
return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W);
|
||||
}
|
||||
|
||||
return new LSL_Rotation();
|
||||
}
|
||||
|
||||
|
@ -8345,17 +8512,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
|
||||
// our key in the object we are in
|
||||
UUID invItemID=InventorySelf();
|
||||
UUID invItemID = InventorySelf();
|
||||
if (invItemID == UUID.Zero) return;
|
||||
|
||||
// the object we are in
|
||||
UUID objectID = m_host.ParentUUID;
|
||||
if (objectID == UUID.Zero) return;
|
||||
|
||||
UUID agentID;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
// we need the permission first, to know which avatar we want to set the camera for
|
||||
UUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
|
||||
agentID = m_host.TaskInventory[invItemID].PermsGranter;
|
||||
|
||||
if (agentID == UUID.Zero) return;
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(agentID);
|
||||
|
||||
|
@ -8404,9 +8576,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (objectID == UUID.Zero) return;
|
||||
|
||||
// we need the permission first, to know which avatar we want to clear the camera for
|
||||
UUID agentID = m_host.TaskInventory[invItemID].PermsGranter;
|
||||
UUID agentID;
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
agentID = m_host.TaskInventory[invItemID].PermsGranter;
|
||||
if (agentID == UUID.Zero) return;
|
||||
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
|
||||
}
|
||||
|
||||
ScenePresence presence = World.GetScenePresence(agentID);
|
||||
|
||||
|
@ -8816,14 +8992,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return new LSL_List();
|
||||
}
|
||||
|
||||
|
||||
internal UUID ScriptByName(string name)
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == 10 && item.Name == name)
|
||||
return item.ItemID;
|
||||
}
|
||||
}
|
||||
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
|
@ -8858,7 +9037,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
|
||||
|
||||
foreach (TaskInventoryItem item in itemsDictionary.Values)
|
||||
{
|
||||
if (item.Type == 7 && item.Name == name)
|
||||
{
|
||||
|
@ -8900,7 +9081,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
|
||||
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
|
||||
|
||||
foreach (TaskInventoryItem item in itemsDictionary.Values)
|
||||
{
|
||||
if (item.Type == 7 && item.Name == name)
|
||||
{
|
||||
|
|
|
@ -231,10 +231,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
m_stateSource = stateSource;
|
||||
m_postOnRez = postOnRez;
|
||||
|
||||
if (part != null && part.TaskInventory.ContainsKey(m_ItemID))
|
||||
if (part != null)
|
||||
{
|
||||
lock (part.TaskInventory)
|
||||
{
|
||||
if (part.TaskInventory.ContainsKey(m_ItemID))
|
||||
{
|
||||
m_thisScriptTask = part.TaskInventory[m_ItemID];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ApiManager am = new ApiManager();
|
||||
|
||||
|
@ -399,15 +405,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
|
||||
private void ReleaseControls()
|
||||
{
|
||||
SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
|
||||
if (part != null && part.TaskInventory.ContainsKey(m_ItemID))
|
||||
SceneObjectPart part = m_Engine.World.GetSceneObjectPart(m_LocalID);
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
UUID permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
|
||||
int permsMask = part.TaskInventory[m_ItemID].PermsMask;
|
||||
int permsMask;
|
||||
UUID permsGranter;
|
||||
lock (part.TaskInventory)
|
||||
{
|
||||
if (!part.TaskInventory.ContainsKey(m_ItemID))
|
||||
return;
|
||||
|
||||
permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
|
||||
permsMask = part.TaskInventory[m_ItemID].PermsMask;
|
||||
}
|
||||
|
||||
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
{
|
||||
|
||||
ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter);
|
||||
if (presence != null)
|
||||
presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID);
|
||||
|
|
Loading…
Reference in New Issue