diff options
author | Melanie | 2012-01-26 00:21:21 +0000 |
---|---|---|
committer | Melanie | 2012-01-26 00:21:21 +0000 |
commit | 4ce42762ee2a8ae323b6a1d118bb4b9b0f447caf (patch) | |
tree | 6173c8da92084547e89db40e5762a74249b4a8db /OpenSim/Region/Framework | |
parent | Typo fix (diff) | |
parent | refactor: change RezScriptFromAgentInventory(), RezNewScript() and AddInvento... (diff) | |
download | opensim-SC-4ce42762ee2a8ae323b6a1d118bb4b9b0f447caf.zip opensim-SC-4ce42762ee2a8ae323b6a1d118bb4b9b0f447caf.tar.gz opensim-SC-4ce42762ee2a8ae323b6a1d118bb4b9b0f447caf.tar.bz2 opensim-SC-4ce42762ee2a8ae323b6a1d118bb4b9b0f447caf.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 182 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 15 |
2 files changed, 108 insertions, 89 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e005698..31d9ce59 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1463,7 +1463,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1463 | // If we've found the item in the user's inventory or in the library | 1463 | // If we've found the item in the user's inventory or in the library |
1464 | if (item != null) | 1464 | if (item != null) |
1465 | { | 1465 | { |
1466 | part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); | 1466 | part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); |
1467 | m_log.InfoFormat( | 1467 | m_log.InfoFormat( |
1468 | "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", | 1468 | "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", |
1469 | item.Name, primLocalID, remoteClient.Name); | 1469 | item.Name, primLocalID, remoteClient.Name); |
@@ -1572,104 +1572,130 @@ namespace OpenSim.Region.Framework.Scenes | |||
1572 | /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory | 1572 | /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory |
1573 | /// </summary> | 1573 | /// </summary> |
1574 | /// <param name="remoteClient"></param> | 1574 | /// <param name="remoteClient"></param> |
1575 | /// <param name="itemID"> </param> | 1575 | /// <param name="itemBase"> </param> |
1576 | /// <param name="transactionID"></param> | ||
1576 | /// <param name="localID"></param> | 1577 | /// <param name="localID"></param> |
1577 | public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) | 1578 | public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) |
1578 | { | 1579 | { |
1579 | UUID itemID = itemBase.ID; | 1580 | SceneObjectPart partWhereRezzed; |
1581 | |||
1582 | if (itemBase.ID != UUID.Zero) | ||
1583 | partWhereRezzed = RezScriptFromAgentInventory(remoteClient.AgentId, itemBase.ID, localID); | ||
1584 | else | ||
1585 | partWhereRezzed = RezNewScript(remoteClient.AgentId, itemBase); | ||
1586 | |||
1587 | if (partWhereRezzed != null) | ||
1588 | partWhereRezzed.SendPropertiesToClient(remoteClient); | ||
1589 | } | ||
1590 | |||
1591 | /// <summary> | ||
1592 | /// Rez a script into a prim from an agent inventory. | ||
1593 | /// </summary> | ||
1594 | /// <param name="agentID"></param> | ||
1595 | /// <param name="fromItemID"></param> | ||
1596 | /// <param name="localID"></param> | ||
1597 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> | ||
1598 | public SceneObjectPart RezScriptFromAgentInventory(UUID agentID, UUID fromItemID, uint localID) | ||
1599 | { | ||
1580 | UUID copyID = UUID.Random(); | 1600 | UUID copyID = UUID.Random(); |
1601 | InventoryItemBase item = new InventoryItemBase(fromItemID, agentID); | ||
1602 | item = InventoryService.GetItem(item); | ||
1581 | 1603 | ||
1582 | if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory | 1604 | // Try library |
1605 | // XXX clumsy, possibly should be one call | ||
1606 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
1583 | { | 1607 | { |
1584 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 1608 | item = LibraryService.LibraryRootFolder.FindItem(fromItemID); |
1585 | item = InventoryService.GetItem(item); | 1609 | } |
1586 | 1610 | ||
1587 | // Try library | 1611 | if (item != null) |
1588 | // XXX clumsy, possibly should be one call | 1612 | { |
1589 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | 1613 | SceneObjectPart part = GetSceneObjectPart(localID); |
1614 | if (part != null) | ||
1590 | { | 1615 | { |
1591 | item = LibraryService.LibraryRootFolder.FindItem(itemID); | 1616 | if (!Permissions.CanEditObjectInventory(part.UUID, agentID)) |
1592 | } | 1617 | return null; |
1593 | 1618 | ||
1594 | if (item != null) | 1619 | part.ParentGroup.AddInventoryItem(agentID, localID, item, copyID); |
1595 | { | 1620 | // TODO: switch to posting on_rez here when scripts |
1596 | SceneObjectPart part = GetSceneObjectPart(localID); | 1621 | // have state in inventory |
1597 | if (part != null) | 1622 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); |
1598 | { | ||
1599 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
1600 | return; | ||
1601 | 1623 | ||
1602 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); | 1624 | // m_log.InfoFormat("[PRIMINVENTORY]: " + |
1603 | // TODO: switch to posting on_rez here when scripts | 1625 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
1604 | // have state in inventory | 1626 | // item.inventoryName, localID, remoteClient.Name); |
1605 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); | 1627 | part.ParentGroup.ResumeScripts(); |
1606 | 1628 | ||
1607 | // m_log.InfoFormat("[PRIMINVENTORY]: " + | 1629 | return part; |
1608 | // "Rezzed script {0} into prim local ID {1} for user {2}", | ||
1609 | // item.inventoryName, localID, remoteClient.Name); | ||
1610 | part.SendPropertiesToClient(remoteClient); | ||
1611 | part.ParentGroup.ResumeScripts(); | ||
1612 | } | ||
1613 | else | ||
1614 | { | ||
1615 | m_log.ErrorFormat( | ||
1616 | "[PRIM INVENTORY]: " + | ||
1617 | "Could not rez script {0} into prim local ID {1} for user {2}" | ||
1618 | + " because the prim could not be found in the region!", | ||
1619 | item.Name, localID, remoteClient.Name); | ||
1620 | } | ||
1621 | } | 1630 | } |
1622 | else | 1631 | else |
1623 | { | 1632 | { |
1624 | m_log.ErrorFormat( | 1633 | m_log.ErrorFormat( |
1625 | "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", | 1634 | "[PRIM INVENTORY]: " + |
1626 | itemID, remoteClient.Name); | 1635 | "Could not rez script {0} into prim local ID {1} for user {2}" |
1636 | + " because the prim could not be found in the region!", | ||
1637 | item.Name, localID, agentID); | ||
1627 | } | 1638 | } |
1628 | } | 1639 | } |
1629 | else // script has been rezzed directly into a prim's inventory | 1640 | else |
1630 | { | 1641 | { |
1631 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); | 1642 | m_log.ErrorFormat( |
1632 | if (part == null) | 1643 | "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", |
1633 | return; | 1644 | fromItemID, agentID); |
1645 | } | ||
1634 | 1646 | ||
1635 | if (!Permissions.CanCreateObjectInventory( | 1647 | return null; |
1636 | itemBase.InvType, part.UUID, remoteClient.AgentId)) | 1648 | } |
1637 | return; | ||
1638 | 1649 | ||
1639 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1650 | /// <summary> |
1640 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), | 1651 | /// Rez a new script from nothing. |
1641 | remoteClient.AgentId); | 1652 | /// </summary> |
1642 | AssetService.Store(asset); | 1653 | /// <param name="remoteClient"></param> |
1654 | /// <param name="itemBase"></param> | ||
1655 | /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> | ||
1656 | public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) | ||
1657 | { | ||
1658 | // The part ID is the folder ID! | ||
1659 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); | ||
1660 | if (part == null) | ||
1661 | return null; | ||
1643 | 1662 | ||
1644 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 1663 | if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID)) |
1645 | 1664 | return null; | |
1646 | taskItem.ResetIDs(itemBase.Folder); | ||
1647 | taskItem.ParentID = itemBase.Folder; | ||
1648 | taskItem.CreationDate = (uint)itemBase.CreationDate; | ||
1649 | taskItem.Name = itemBase.Name; | ||
1650 | taskItem.Description = itemBase.Description; | ||
1651 | taskItem.Type = itemBase.AssetType; | ||
1652 | taskItem.InvType = itemBase.InvType; | ||
1653 | taskItem.OwnerID = itemBase.Owner; | ||
1654 | taskItem.CreatorID = itemBase.CreatorIdAsUuid; | ||
1655 | taskItem.BasePermissions = itemBase.BasePermissions; | ||
1656 | taskItem.CurrentPermissions = itemBase.CurrentPermissions; | ||
1657 | taskItem.EveryonePermissions = itemBase.EveryOnePermissions; | ||
1658 | taskItem.GroupPermissions = itemBase.GroupPermissions; | ||
1659 | taskItem.NextPermissions = itemBase.NextPermissions; | ||
1660 | taskItem.GroupID = itemBase.GroupID; | ||
1661 | taskItem.GroupPermissions = 0; | ||
1662 | taskItem.Flags = itemBase.Flags; | ||
1663 | taskItem.PermsGranter = UUID.Zero; | ||
1664 | taskItem.PermsMask = 0; | ||
1665 | taskItem.AssetID = asset.FullID; | ||
1666 | |||
1667 | part.Inventory.AddInventoryItem(taskItem, false); | ||
1668 | part.SendPropertiesToClient(remoteClient); | ||
1669 | 1665 | ||
1670 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | 1666 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1671 | part.ParentGroup.ResumeScripts(); | 1667 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1672 | } | 1668 | agentID); |
1669 | AssetService.Store(asset); | ||
1670 | |||
1671 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1672 | |||
1673 | taskItem.ResetIDs(itemBase.Folder); | ||
1674 | taskItem.ParentID = itemBase.Folder; | ||
1675 | taskItem.CreationDate = (uint)itemBase.CreationDate; | ||
1676 | taskItem.Name = itemBase.Name; | ||
1677 | taskItem.Description = itemBase.Description; | ||
1678 | taskItem.Type = itemBase.AssetType; | ||
1679 | taskItem.InvType = itemBase.InvType; | ||
1680 | taskItem.OwnerID = itemBase.Owner; | ||
1681 | taskItem.CreatorID = itemBase.CreatorIdAsUuid; | ||
1682 | taskItem.BasePermissions = itemBase.BasePermissions; | ||
1683 | taskItem.CurrentPermissions = itemBase.CurrentPermissions; | ||
1684 | taskItem.EveryonePermissions = itemBase.EveryOnePermissions; | ||
1685 | taskItem.GroupPermissions = itemBase.GroupPermissions; | ||
1686 | taskItem.NextPermissions = itemBase.NextPermissions; | ||
1687 | taskItem.GroupID = itemBase.GroupID; | ||
1688 | taskItem.GroupPermissions = 0; | ||
1689 | taskItem.Flags = itemBase.Flags; | ||
1690 | taskItem.PermsGranter = UUID.Zero; | ||
1691 | taskItem.PermsMask = 0; | ||
1692 | taskItem.AssetID = asset.FullID; | ||
1693 | |||
1694 | part.Inventory.AddInventoryItem(taskItem, false); | ||
1695 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | ||
1696 | part.ParentGroup.ResumeScripts(); | ||
1697 | |||
1698 | return part; | ||
1673 | } | 1699 | } |
1674 | 1700 | ||
1675 | /// <summary> | 1701 | /// <summary> |
@@ -1678,7 +1704,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1678 | /// <param name="remoteClient"></param> | 1704 | /// <param name="remoteClient"></param> |
1679 | /// <param name="itemID"> </param> | 1705 | /// <param name="itemID"> </param> |
1680 | /// <param name="localID"></param> | 1706 | /// <param name="localID"></param> |
1681 | public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) | 1707 | public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) |
1682 | { | 1708 | { |
1683 | TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); | 1709 | TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); |
1684 | 1710 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index c7da4f4..b56d3fc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -79,13 +79,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
79 | /// <summary> | 79 | /// <summary> |
80 | /// Add an inventory item from a user's inventory to a prim in this scene object. | 80 | /// Add an inventory item from a user's inventory to a prim in this scene object. |
81 | /// </summary> | 81 | /// </summary> |
82 | /// <param name="remoteClient">The client adding the item.</param> | 82 | /// <param name="agentID">The agent adding the item.</param> |
83 | /// <param name="localID">The local ID of the part receiving the add.</param> | 83 | /// <param name="localID">The local ID of the part receiving the add.</param> |
84 | /// <param name="item">The user inventory item being added.</param> | 84 | /// <param name="item">The user inventory item being added.</param> |
85 | /// <param name="copyItemID">The item UUID that should be used by the new item.</param> | 85 | /// <param name="copyItemID">The item UUID that should be used by the new item.</param> |
86 | /// <returns></returns> | 86 | /// <returns></returns> |
87 | public bool AddInventoryItem(IClientAPI remoteClient, uint localID, | 87 | public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID) |
88 | InventoryItemBase item, UUID copyItemID) | ||
89 | { | 88 | { |
90 | // m_log.DebugFormat( | 89 | // m_log.DebugFormat( |
91 | // "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", | 90 | // "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", |
@@ -107,9 +106,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
107 | taskItem.Type = item.AssetType; | 106 | taskItem.Type = item.AssetType; |
108 | taskItem.InvType = item.InvType; | 107 | taskItem.InvType = item.InvType; |
109 | 108 | ||
110 | if (remoteClient != null && | 109 | if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions()) |
111 | remoteClient.AgentId != part.OwnerID && | ||
112 | m_scene.Permissions.PropagatePermissions()) | ||
113 | { | 110 | { |
114 | taskItem.BasePermissions = item.BasePermissions & | 111 | taskItem.BasePermissions = item.BasePermissions & |
115 | item.NextPermissions; | 112 | item.NextPermissions; |
@@ -144,11 +141,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | // taskItem.SaleType = item.SaleType; | 141 | // taskItem.SaleType = item.SaleType; |
145 | taskItem.CreationDate = (uint)item.CreationDate; | 142 | taskItem.CreationDate = (uint)item.CreationDate; |
146 | 143 | ||
147 | bool addFromAllowedDrop = false; | 144 | bool addFromAllowedDrop = agentID != part.OwnerID; |
148 | if (remoteClient != null) | ||
149 | { | ||
150 | addFromAllowedDrop = remoteClient.AgentId != part.OwnerID; | ||
151 | } | ||
152 | 145 | ||
153 | part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); | 146 | part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); |
154 | 147 | ||