diff options
author | Justin Clark-Casey (justincc) | 2012-01-25 23:22:07 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-01-25 23:22:07 +0000 |
commit | 2de3a1b9dad25855cb18a29f2c43ad67cfb0730c (patch) | |
tree | 426bd46a79ddf1ad8f37937364e2fcfd2ce3a14a /OpenSim/Region | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-2de3a1b9dad25855cb18a29f2c43ad67cfb0730c.zip opensim-SC_OLD-2de3a1b9dad25855cb18a29f2c43ad67cfb0730c.tar.gz opensim-SC_OLD-2de3a1b9dad25855cb18a29f2c43ad67cfb0730c.tar.bz2 opensim-SC_OLD-2de3a1b9dad25855cb18a29f2c43ad67cfb0730c.tar.xz |
refactor: decompose most of RezScript() into RezScriptFromAgentInventory(), RezNewScript() and rename one RezScript() to RezScriptFromPrim()
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 174 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 |
2 files changed, 97 insertions, 80 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2444367..f4f37ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1560,104 +1560,120 @@ namespace OpenSim.Region.Framework.Scenes | |||
1560 | /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory | 1560 | /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory |
1561 | /// </summary> | 1561 | /// </summary> |
1562 | /// <param name="remoteClient"></param> | 1562 | /// <param name="remoteClient"></param> |
1563 | /// <param name="itemID"> </param> | 1563 | /// <param name="itemBase"> </param> |
1564 | /// <param name="transactionID"></param> | ||
1564 | /// <param name="localID"></param> | 1565 | /// <param name="localID"></param> |
1565 | public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) | 1566 | public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) |
1566 | { | 1567 | { |
1567 | UUID itemID = itemBase.ID; | 1568 | if (itemBase.ID != UUID.Zero) |
1569 | RezScriptFromAgentInventory(remoteClient, itemBase.ID, localID); | ||
1570 | else | ||
1571 | RezNewScript(remoteClient, itemBase); | ||
1572 | } | ||
1573 | |||
1574 | /// <summary> | ||
1575 | /// Rez a script into a prim from an agent inventory. | ||
1576 | /// </summary> | ||
1577 | /// <param name="remoteClient"></param> | ||
1578 | /// <param name="fromItemID"></param> | ||
1579 | /// <param name="localID"></param> | ||
1580 | public void RezScriptFromAgentInventory(IClientAPI remoteClient, UUID fromItemID, uint localID) | ||
1581 | { | ||
1568 | UUID copyID = UUID.Random(); | 1582 | UUID copyID = UUID.Random(); |
1583 | InventoryItemBase item = new InventoryItemBase(fromItemID, remoteClient.AgentId); | ||
1584 | item = InventoryService.GetItem(item); | ||
1569 | 1585 | ||
1570 | if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory | 1586 | // Try library |
1587 | // XXX clumsy, possibly should be one call | ||
1588 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
1571 | { | 1589 | { |
1572 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 1590 | item = LibraryService.LibraryRootFolder.FindItem(fromItemID); |
1573 | item = InventoryService.GetItem(item); | 1591 | } |
1574 | |||
1575 | // Try library | ||
1576 | // XXX clumsy, possibly should be one call | ||
1577 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
1578 | { | ||
1579 | item = LibraryService.LibraryRootFolder.FindItem(itemID); | ||
1580 | } | ||
1581 | 1592 | ||
1582 | if (item != null) | 1593 | if (item != null) |
1594 | { | ||
1595 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1596 | if (part != null) | ||
1583 | { | 1597 | { |
1584 | SceneObjectPart part = GetSceneObjectPart(localID); | 1598 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) |
1585 | if (part != null) | 1599 | return; |
1586 | { | ||
1587 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
1588 | return; | ||
1589 | 1600 | ||
1590 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); | 1601 | part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); |
1591 | // TODO: switch to posting on_rez here when scripts | 1602 | // TODO: switch to posting on_rez here when scripts |
1592 | // have state in inventory | 1603 | // have state in inventory |
1593 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); | 1604 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); |
1594 | 1605 | ||
1595 | // m_log.InfoFormat("[PRIMINVENTORY]: " + | 1606 | // m_log.InfoFormat("[PRIMINVENTORY]: " + |
1596 | // "Rezzed script {0} into prim local ID {1} for user {2}", | 1607 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
1597 | // item.inventoryName, localID, remoteClient.Name); | 1608 | // item.inventoryName, localID, remoteClient.Name); |
1598 | part.SendPropertiesToClient(remoteClient); | 1609 | part.SendPropertiesToClient(remoteClient); |
1599 | part.ParentGroup.ResumeScripts(); | 1610 | part.ParentGroup.ResumeScripts(); |
1600 | } | ||
1601 | else | ||
1602 | { | ||
1603 | m_log.ErrorFormat( | ||
1604 | "[PRIM INVENTORY]: " + | ||
1605 | "Could not rez script {0} into prim local ID {1} for user {2}" | ||
1606 | + " because the prim could not be found in the region!", | ||
1607 | item.Name, localID, remoteClient.Name); | ||
1608 | } | ||
1609 | } | 1611 | } |
1610 | else | 1612 | else |
1611 | { | 1613 | { |
1612 | m_log.ErrorFormat( | 1614 | m_log.ErrorFormat( |
1613 | "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", | 1615 | "[PRIM INVENTORY]: " + |
1614 | itemID, remoteClient.Name); | 1616 | "Could not rez script {0} into prim local ID {1} for user {2}" |
1617 | + " because the prim could not be found in the region!", | ||
1618 | item.Name, localID, remoteClient.Name); | ||
1615 | } | 1619 | } |
1616 | } | 1620 | } |
1617 | else // script has been rezzed directly into a prim's inventory | 1621 | else |
1618 | { | 1622 | { |
1619 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); | 1623 | m_log.ErrorFormat( |
1620 | if (part == null) | 1624 | "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", |
1621 | return; | 1625 | fromItemID, remoteClient.Name); |
1626 | } | ||
1627 | } | ||
1622 | 1628 | ||
1623 | if (!Permissions.CanCreateObjectInventory( | 1629 | /// <summary> |
1624 | itemBase.InvType, part.UUID, remoteClient.AgentId)) | 1630 | /// Rez a new script from nothing. |
1625 | return; | 1631 | /// </summary> |
1632 | /// <param name="remoteClient"></param> | ||
1633 | /// <param name="itemBase"></param> | ||
1634 | public void RezNewScript(IClientAPI remoteClient, InventoryItemBase itemBase) | ||
1635 | { | ||
1636 | SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); | ||
1637 | if (part == null) | ||
1638 | return; | ||
1626 | 1639 | ||
1627 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1640 | if (!Permissions.CanCreateObjectInventory( |
1628 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1641 | itemBase.InvType, part.UUID, remoteClient.AgentId)) |
1629 | remoteClient.AgentId); | 1642 | return; |
1630 | AssetService.Store(asset); | ||
1631 | |||
1632 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1633 | |||
1634 | taskItem.ResetIDs(itemBase.Folder); | ||
1635 | taskItem.ParentID = itemBase.Folder; | ||
1636 | taskItem.CreationDate = (uint)itemBase.CreationDate; | ||
1637 | taskItem.Name = itemBase.Name; | ||
1638 | taskItem.Description = itemBase.Description; | ||
1639 | taskItem.Type = itemBase.AssetType; | ||
1640 | taskItem.InvType = itemBase.InvType; | ||
1641 | taskItem.OwnerID = itemBase.Owner; | ||
1642 | taskItem.CreatorID = itemBase.CreatorIdAsUuid; | ||
1643 | taskItem.BasePermissions = itemBase.BasePermissions; | ||
1644 | taskItem.CurrentPermissions = itemBase.CurrentPermissions; | ||
1645 | taskItem.EveryonePermissions = itemBase.EveryOnePermissions; | ||
1646 | taskItem.GroupPermissions = itemBase.GroupPermissions; | ||
1647 | taskItem.NextPermissions = itemBase.NextPermissions; | ||
1648 | taskItem.GroupID = itemBase.GroupID; | ||
1649 | taskItem.GroupPermissions = 0; | ||
1650 | taskItem.Flags = itemBase.Flags; | ||
1651 | taskItem.PermsGranter = UUID.Zero; | ||
1652 | taskItem.PermsMask = 0; | ||
1653 | taskItem.AssetID = asset.FullID; | ||
1654 | |||
1655 | part.Inventory.AddInventoryItem(taskItem, false); | ||
1656 | part.SendPropertiesToClient(remoteClient); | ||
1657 | 1643 | ||
1658 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | 1644 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1659 | part.ParentGroup.ResumeScripts(); | 1645 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), |
1660 | } | 1646 | remoteClient.AgentId); |
1647 | AssetService.Store(asset); | ||
1648 | |||
1649 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1650 | |||
1651 | taskItem.ResetIDs(itemBase.Folder); | ||
1652 | taskItem.ParentID = itemBase.Folder; | ||
1653 | taskItem.CreationDate = (uint)itemBase.CreationDate; | ||
1654 | taskItem.Name = itemBase.Name; | ||
1655 | taskItem.Description = itemBase.Description; | ||
1656 | taskItem.Type = itemBase.AssetType; | ||
1657 | taskItem.InvType = itemBase.InvType; | ||
1658 | taskItem.OwnerID = itemBase.Owner; | ||
1659 | taskItem.CreatorID = itemBase.CreatorIdAsUuid; | ||
1660 | taskItem.BasePermissions = itemBase.BasePermissions; | ||
1661 | taskItem.CurrentPermissions = itemBase.CurrentPermissions; | ||
1662 | taskItem.EveryonePermissions = itemBase.EveryOnePermissions; | ||
1663 | taskItem.GroupPermissions = itemBase.GroupPermissions; | ||
1664 | taskItem.NextPermissions = itemBase.NextPermissions; | ||
1665 | taskItem.GroupID = itemBase.GroupID; | ||
1666 | taskItem.GroupPermissions = 0; | ||
1667 | taskItem.Flags = itemBase.Flags; | ||
1668 | taskItem.PermsGranter = UUID.Zero; | ||
1669 | taskItem.PermsMask = 0; | ||
1670 | taskItem.AssetID = asset.FullID; | ||
1671 | |||
1672 | part.Inventory.AddInventoryItem(taskItem, false); | ||
1673 | part.SendPropertiesToClient(remoteClient); | ||
1674 | |||
1675 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | ||
1676 | part.ParentGroup.ResumeScripts(); | ||
1661 | } | 1677 | } |
1662 | 1678 | ||
1663 | /// <summary> | 1679 | /// <summary> |
@@ -1666,7 +1682,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1666 | /// <param name="remoteClient"></param> | 1682 | /// <param name="remoteClient"></param> |
1667 | /// <param name="itemID"> </param> | 1683 | /// <param name="itemID"> </param> |
1668 | /// <param name="localID"></param> | 1684 | /// <param name="localID"></param> |
1669 | public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) | 1685 | public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) |
1670 | { | 1686 | { |
1671 | TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); | 1687 | TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); |
1672 | 1688 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 330c65d..6fa812d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -6603,7 +6603,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6603 | } | 6603 | } |
6604 | 6604 | ||
6605 | // the rest of the permission checks are done in RezScript, so check the pin there as well | 6605 | // the rest of the permission checks are done in RezScript, so check the pin there as well |
6606 | World.RezScript(srcId, m_host, destId, pin, running, start_param); | 6606 | World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); |
6607 | |||
6607 | // this will cause the delay even if the script pin or permissions were wrong - seems ok | 6608 | // this will cause the delay even if the script pin or permissions were wrong - seems ok |
6608 | ScriptSleep(3000); | 6609 | ScriptSleep(3000); |
6609 | } | 6610 | } |