aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-01-26 00:10:37 +0000
committerJustin Clark-Casey (justincc)2012-01-26 00:10:37 +0000
commit55c6cbabfd04599030548983f376f60acdf607e7 (patch)
treeacb78bec49b2b92beaf4bb8bfa691c0e43308f52 /OpenSim/Region
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-55c6cbabfd04599030548983f376f60acdf607e7.zip
opensim-SC_OLD-55c6cbabfd04599030548983f376f60acdf607e7.tar.gz
opensim-SC_OLD-55c6cbabfd04599030548983f376f60acdf607e7.tar.bz2
opensim-SC_OLD-55c6cbabfd04599030548983f376f60acdf607e7.tar.xz
refactor: change RezScriptFromAgentInventory(), RezNewScript() and AddInventoryItem() to accept an agent id rather than a full IClientAPI.
This stops some code having to make spurious client == null checks and reduces regression test complexity.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs15
2 files changed, 34 insertions, 31 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index f4f37ac..9293aeb 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1444,7 +1444,7 @@ namespace OpenSim.Region.Framework.Scenes
1444 // If we've found the item in the user's inventory or in the library 1444 // If we've found the item in the user's inventory or in the library
1445 if (item != null) 1445 if (item != null)
1446 { 1446 {
1447 part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); 1447 part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID);
1448 m_log.InfoFormat( 1448 m_log.InfoFormat(
1449 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1449 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1450 item.Name, primLocalID, remoteClient.Name); 1450 item.Name, primLocalID, remoteClient.Name);
@@ -1565,22 +1565,28 @@ namespace OpenSim.Region.Framework.Scenes
1565 /// <param name="localID"></param> 1565 /// <param name="localID"></param>
1566 public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) 1566 public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID)
1567 { 1567 {
1568 SceneObjectPart partWhereRezzed;
1569
1568 if (itemBase.ID != UUID.Zero) 1570 if (itemBase.ID != UUID.Zero)
1569 RezScriptFromAgentInventory(remoteClient, itemBase.ID, localID); 1571 partWhereRezzed = RezScriptFromAgentInventory(remoteClient.AgentId, itemBase.ID, localID);
1570 else 1572 else
1571 RezNewScript(remoteClient, itemBase); 1573 partWhereRezzed = RezNewScript(remoteClient.AgentId, itemBase);
1574
1575 if (partWhereRezzed != null)
1576 partWhereRezzed.SendPropertiesToClient(remoteClient);
1572 } 1577 }
1573 1578
1574 /// <summary> 1579 /// <summary>
1575 /// Rez a script into a prim from an agent inventory. 1580 /// Rez a script into a prim from an agent inventory.
1576 /// </summary> 1581 /// </summary>
1577 /// <param name="remoteClient"></param> 1582 /// <param name="agentID"></param>
1578 /// <param name="fromItemID"></param> 1583 /// <param name="fromItemID"></param>
1579 /// <param name="localID"></param> 1584 /// <param name="localID"></param>
1580 public void RezScriptFromAgentInventory(IClientAPI remoteClient, UUID fromItemID, uint localID) 1585 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1586 public SceneObjectPart RezScriptFromAgentInventory(UUID agentID, UUID fromItemID, uint localID)
1581 { 1587 {
1582 UUID copyID = UUID.Random(); 1588 UUID copyID = UUID.Random();
1583 InventoryItemBase item = new InventoryItemBase(fromItemID, remoteClient.AgentId); 1589 InventoryItemBase item = new InventoryItemBase(fromItemID, agentID);
1584 item = InventoryService.GetItem(item); 1590 item = InventoryService.GetItem(item);
1585 1591
1586 // Try library 1592 // Try library
@@ -1595,10 +1601,10 @@ namespace OpenSim.Region.Framework.Scenes
1595 SceneObjectPart part = GetSceneObjectPart(localID); 1601 SceneObjectPart part = GetSceneObjectPart(localID);
1596 if (part != null) 1602 if (part != null)
1597 { 1603 {
1598 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) 1604 if (!Permissions.CanEditObjectInventory(part.UUID, agentID))
1599 return; 1605 return null;
1600 1606
1601 part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); 1607 part.ParentGroup.AddInventoryItem(agentID, localID, item, copyID);
1602 // TODO: switch to posting on_rez here when scripts 1608 // TODO: switch to posting on_rez here when scripts
1603 // have state in inventory 1609 // have state in inventory
1604 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); 1610 part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
@@ -1606,8 +1612,9 @@ namespace OpenSim.Region.Framework.Scenes
1606 // m_log.InfoFormat("[PRIMINVENTORY]: " + 1612 // m_log.InfoFormat("[PRIMINVENTORY]: " +
1607 // "Rezzed script {0} into prim local ID {1} for user {2}", 1613 // "Rezzed script {0} into prim local ID {1} for user {2}",
1608 // item.inventoryName, localID, remoteClient.Name); 1614 // item.inventoryName, localID, remoteClient.Name);
1609 part.SendPropertiesToClient(remoteClient);
1610 part.ParentGroup.ResumeScripts(); 1615 part.ParentGroup.ResumeScripts();
1616
1617 return part;
1611 } 1618 }
1612 else 1619 else
1613 { 1620 {
@@ -1615,15 +1622,17 @@ namespace OpenSim.Region.Framework.Scenes
1615 "[PRIM INVENTORY]: " + 1622 "[PRIM INVENTORY]: " +
1616 "Could not rez script {0} into prim local ID {1} for user {2}" 1623 "Could not rez script {0} into prim local ID {1} for user {2}"
1617 + " because the prim could not be found in the region!", 1624 + " because the prim could not be found in the region!",
1618 item.Name, localID, remoteClient.Name); 1625 item.Name, localID, agentID);
1619 } 1626 }
1620 } 1627 }
1621 else 1628 else
1622 { 1629 {
1623 m_log.ErrorFormat( 1630 m_log.ErrorFormat(
1624 "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", 1631 "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
1625 fromItemID, remoteClient.Name); 1632 fromItemID, agentID);
1626 } 1633 }
1634
1635 return null;
1627 } 1636 }
1628 1637
1629 /// <summary> 1638 /// <summary>
@@ -1631,19 +1640,20 @@ namespace OpenSim.Region.Framework.Scenes
1631 /// </summary> 1640 /// </summary>
1632 /// <param name="remoteClient"></param> 1641 /// <param name="remoteClient"></param>
1633 /// <param name="itemBase"></param> 1642 /// <param name="itemBase"></param>
1634 public void RezNewScript(IClientAPI remoteClient, InventoryItemBase itemBase) 1643 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1644 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase)
1635 { 1645 {
1646 // The part ID is the folder ID!
1636 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); 1647 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
1637 if (part == null) 1648 if (part == null)
1638 return; 1649 return null;
1639 1650
1640 if (!Permissions.CanCreateObjectInventory( 1651 if (!Permissions.CanCreateObjectInventory(itemBase.InvType, part.UUID, agentID))
1641 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1652 return null;
1642 return;
1643 1653
1644 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1654 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1645 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), 1655 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
1646 remoteClient.AgentId); 1656 agentID);
1647 AssetService.Store(asset); 1657 AssetService.Store(asset);
1648 1658
1649 TaskInventoryItem taskItem = new TaskInventoryItem(); 1659 TaskInventoryItem taskItem = new TaskInventoryItem();
@@ -1670,10 +1680,10 @@ namespace OpenSim.Region.Framework.Scenes
1670 taskItem.AssetID = asset.FullID; 1680 taskItem.AssetID = asset.FullID;
1671 1681
1672 part.Inventory.AddInventoryItem(taskItem, false); 1682 part.Inventory.AddInventoryItem(taskItem, false);
1673 part.SendPropertiesToClient(remoteClient);
1674
1675 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1683 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1676 part.ParentGroup.ResumeScripts(); 1684 part.ParentGroup.ResumeScripts();
1685
1686 return part;
1677 } 1687 }
1678 1688
1679 /// <summary> 1689 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 905ecc9..f173c95 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -83,13 +83,12 @@ namespace OpenSim.Region.Framework.Scenes
83 /// <summary> 83 /// <summary>
84 /// Add an inventory item from a user's inventory to a prim in this scene object. 84 /// Add an inventory item from a user's inventory to a prim in this scene object.
85 /// </summary> 85 /// </summary>
86 /// <param name="remoteClient">The client adding the item.</param> 86 /// <param name="agentID">The agent adding the item.</param>
87 /// <param name="localID">The local ID of the part receiving the add.</param> 87 /// <param name="localID">The local ID of the part receiving the add.</param>
88 /// <param name="item">The user inventory item being added.</param> 88 /// <param name="item">The user inventory item being added.</param>
89 /// <param name="copyItemID">The item UUID that should be used by the new item.</param> 89 /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
90 /// <returns></returns> 90 /// <returns></returns>
91 public bool AddInventoryItem(IClientAPI remoteClient, uint localID, 91 public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID)
92 InventoryItemBase item, UUID copyItemID)
93 { 92 {
94// m_log.DebugFormat( 93// m_log.DebugFormat(
95// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", 94// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}",
@@ -111,9 +110,7 @@ namespace OpenSim.Region.Framework.Scenes
111 taskItem.Type = item.AssetType; 110 taskItem.Type = item.AssetType;
112 taskItem.InvType = item.InvType; 111 taskItem.InvType = item.InvType;
113 112
114 if (remoteClient != null && 113 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
115 remoteClient.AgentId != part.OwnerID &&
116 m_scene.Permissions.PropagatePermissions())
117 { 114 {
118 taskItem.BasePermissions = item.BasePermissions & 115 taskItem.BasePermissions = item.BasePermissions &
119 item.NextPermissions; 116 item.NextPermissions;
@@ -148,11 +145,7 @@ namespace OpenSim.Region.Framework.Scenes
148// taskItem.SaleType = item.SaleType; 145// taskItem.SaleType = item.SaleType;
149 taskItem.CreationDate = (uint)item.CreationDate; 146 taskItem.CreationDate = (uint)item.CreationDate;
150 147
151 bool addFromAllowedDrop = false; 148 bool addFromAllowedDrop = agentID != part.OwnerID;
152 if (remoteClient != null)
153 {
154 addFromAllowedDrop = remoteClient.AgentId != part.OwnerID;
155 }
156 149
157 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); 150 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
158 151