aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs50
1 files changed, 30 insertions, 20 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>