diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 8350802a8b..608a032eb0 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -146,6 +146,7 @@ what it is today. * Stefan_Boom / stoehr * Strawberry Fride * Talun +* TechplexEngineer (Blake Bourque) * TBG Renfold * tglion * tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud) diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 30ed7d100d..4370fcc96f 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -163,6 +163,19 @@ namespace OpenSim.Region.Framework.Interfaces /// List GetInventoryItems(); + /// + /// Gets an inventory item by name + /// + /// + /// This method returns the first inventory item that matches the given name. In SL this is all you need + /// since each item in a prim inventory must have a unique name. + /// + /// + /// + /// The inventory item. Null if no such item was found. + /// + TaskInventoryItem GetInventoryItem(string name); + /// /// Get inventory items by name. /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 98a75e49a9..ce386be205 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1032,13 +1032,13 @@ namespace OpenSim.Region.Framework.Scenes } } + m_log.Error("[REGION]: Closing"); + Close(); + if (PhysicsScene != null) { PhysicsScene.Dispose(); - } - - m_log.Error("[REGION]: Closing"); - Close(); + } m_log.Error("[REGION]: Firing Region Restart Message"); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index aaf9ffac7b..8810903700 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -582,14 +582,20 @@ namespace OpenSim.Region.Framework.Scenes return item; } - /// - /// Get inventory items by name. - /// - /// - /// - /// A list of inventory items with that name. - /// If no inventory item has that name then an empty list is returned. - /// + public TaskInventoryItem GetInventoryItem(string name) + { + lock (m_items) + { + foreach (TaskInventoryItem item in m_items.Values) + { + if (item.Name == name) + return item; + } + } + + return null; + } + public List GetInventoryItems(string name) { List items = new List(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4b2880837e..deb68b83f4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -104,9 +104,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected int m_scriptConsoleChannel = 0; protected bool m_scriptConsoleChannelEnabled = false; protected IUrlModule m_UrlModule = null; - protected Dictionary m_userInfoCache = - new Dictionary(); - protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. + protected Dictionary m_userInfoCache = new Dictionary(); + protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) { @@ -285,44 +284,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected UUID InventoryKey(string name, int type) { - m_host.AddScriptLPS(1); + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Name == name) - { - if (inv.Value.Type != type) - return UUID.Zero; - - return inv.Value.AssetID; - } - } - } - - return UUID.Zero; + if (item != null && item.Type == type) + return item.AssetID; + else + return UUID.Zero; } - protected UUID InventoryKey(string name) - { - m_host.AddScriptLPS(1); - - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Name == name) - { - return inv.Value.AssetID; - } - } - } - - return UUID.Zero; - } - - /// /// accepts a valid UUID, -or- a name of an inventory item. /// Returns a valid UUID or UUID.Zero if key invalid and item not found @@ -332,19 +301,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// protected UUID KeyOrName(string k) { - UUID key = UUID.Zero; + UUID key; // if we can parse the string as a key, use it. - if (UUID.TryParse(k, out key)) - { - return key; - } // else try to locate the name in inventory of object. found returns key, - // not found returns UUID.Zero which will translate to the default particle texture - else + // not found returns UUID.Zero + if (!UUID.TryParse(k, out key)) { - return InventoryKey(k); + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); + + if (item != null) + key = item.AssetID; + else + key = UUID.Zero; } + + return key; } // convert a LSL_Rotation to a Quaternion @@ -1724,14 +1696,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return rgb; } + if (face >= 0 && face < GetNumberOfSides(part)) { texcolor = tex.GetFace((uint)face).RGBA; rgb.x = texcolor.R; rgb.y = texcolor.G; rgb.z = texcolor.B; + return rgb; - } else { @@ -3315,17 +3288,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) { - UUID animID = new UUID(); - - if (!UUID.TryParse(anim, out animID)) - { - animID = InventoryKey(anim); - } - ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); if (presence != null) { + UUID animID = KeyOrName(anim); + if (animID == UUID.Zero) presence.Animator.RemoveAnimation(anim); else @@ -3438,9 +3406,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } ScenePresence presence = World.GetScenePresence(agentID); - if (presence != null) { + // If permissions are being requested from an NPC and were not implicitly granted above then + // auto grant all reuqested permissions if the script is owned by the NPC or the NPCs owner + INPCModule npcModule = World.RequestModuleInterface(); + if (npcModule != null && npcModule.IsNPC(agentID, World)) + { + if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID) + { + lock (m_host.TaskInventory) + { + m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; + m_host.TaskInventory[m_item.ItemID].PermsMask = perm; + } + + m_ScriptEngine.PostScriptEvent( + m_item.ItemID, + new EventParams( + "run_time_permissions", new Object[] { new LSL_Integer(perm) }, new DetectParams[0])); + } + + // it is an NPC, exit even if the permissions werent granted above, they are not going to answer + // the question! + return; + } + string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); if (ownerName == String.Empty) ownerName = "(hippos)"; @@ -3464,10 +3455,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // Requested agent is not in range, refuse perms - m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(0) }, - new DetectParams[0])); + m_ScriptEngine.PostScriptEvent( + m_item.ItemID, + new EventParams("run_time_permissions", new Object[] { new LSL_Integer(0) }, new DetectParams[0])); } void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) @@ -3486,10 +3476,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.TaskInventory[m_item.ItemID].PermsMask = answer; } - m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(answer) }, - new DetectParams[0])); + m_ScriptEngine.PostScriptEvent( + m_item.ItemID, + new EventParams("run_time_permissions", new Object[] { new LSL_Integer(answer) }, new DetectParams[0])); } public LSL_String llGetPermissionsKey() @@ -9130,7 +9119,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api GridRegion info; - if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) + if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) //Det data for this simulator? + info = new GridRegion(m_ScriptEngine.World.RegionInfo); else info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); @@ -9143,10 +9133,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(1000); return UUID.Zero.ToString(); } - reply = new LSL_Vector( - info.RegionLocX, - info.RegionLocY, - 0).ToString(); + if (m_ScriptEngine.World.RegionInfo.RegionName != simulator) + { + //Hypergrid Region co-ordinates + uint rx = 0, ry = 0; + Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out rx, out ry); + + reply = new LSL_Vector( + rx, + ry, + 0).ToString(); + } + else + { + //Local-cooridnates + reply = new LSL_Vector( + info.RegionLocX, + info.RegionLocY, + 0).ToString(); + } break; case ScriptBaseClass.DATA_SIM_STATUS: if (info != null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ad1a3585ca..7ea8b7a4fb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -952,23 +952,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID avatarID = (UUID)avatar; m_host.AddScriptLPS(1); + + // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common + // method (though see that doesn't do the is animation check, which is probably a bug) and have both + // these functions call that common code. However, this does mean navigating the brain-dead requirement + // of calling InitLSL() if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) { ScenePresence target = (ScenePresence)World.Entities[avatarID]; if (target != null) { - UUID animID = UUID.Zero; - lock (m_host.TaskInventory) + UUID animID; + + if (!UUID.TryParse(animation, out animID)) { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Name == animation) - { - if (inv.Value.Type == (int)AssetType.Animation) - animID = inv.Value.AssetID; - continue; - } - } + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); + if (item != null && item.Type == (int)AssetType.Animation) + animID = item.AssetID; + else + animID = UUID.Zero; } if (animID == UUID.Zero)