From 796ae57bea5e7004ac8d41bee2d496d645db81ce Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 9 Jan 2008 15:46:45 +0000
Subject: Prim inventory script saving phase 2. * It is now possible to edit
and save scripts directly from prim inventories * On saving, the script will
be restarted in the region * Doesn't appear that it's yet possible to drag
inventory contents back to agent inventory. Not quite sure why this is yet -
the perms all look very permissive.
---
.../Scenes/SceneObjectPart.Inventory.cs | 107 +++++++++++++++++----
1 file changed, 89 insertions(+), 18 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs')
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 9e2c256..5d197e3 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -144,7 +144,26 @@ namespace OpenSim.Region.Environment.Scenes
itemId, Name, UUID);
}
- }
+ }
+
+ ///
+ /// Stop a script which is in this prim's inventory.
+ ///
+ ///
+ public void StopScript(LLUUID itemId)
+ {
+ if (m_taskInventory.ContainsKey(itemId))
+ {
+ m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalID, itemId);
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}",
+ itemId, Name, UUID);
+ }
+ }
///
/// Add an item to this prim's inventory.
@@ -173,33 +192,85 @@ namespace OpenSim.Region.Environment.Scenes
m_inventorySerial++;
}
+
+ ///
+ /// Returns an existing inventory item. Returns the original, so any changes will be live.
+ ///
+ ///
+ /// null if the item does not exist
+ public TaskInventoryItem GetInventoryItem(LLUUID itemID)
+ {
+ if (m_taskInventory.ContainsKey(itemID))
+ {
+ return m_taskInventory[itemID];
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ itemID, Name, UUID);
+ }
+
+ return null;
+ }
+
+ ///
+ /// Update an existing inventory item.
+ ///
+ /// The updated item. An item with the same id must already exist
+ /// in this prim's inventory.
+ /// false if the item did not exist, true if the update occurred succesfully
+ public bool UpdateInventoryItem(TaskInventoryItem item)
+ {
+ if (m_taskInventory.ContainsKey(item.item_id))
+ {
+ m_taskInventory[item.item_id] = item;
+ m_inventorySerial++;
+
+ return true;
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ item.item_id, Name, UUID);
+ }
+
+ return false;
+ }
///
/// Remove an item from this prim's inventory
///
- ///
- ///
///
- /// Numeric asset type of the item removed.
- public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
+ /// Numeric asset type of the item removed. Returns -1 if the item did not exist
+ /// in this prim's inventory.
+ public int RemoveInventoryItem(LLUUID itemID)
{
- if (localID == LocalID)
+ if (m_taskInventory.ContainsKey(itemID))
{
- if (m_taskInventory.ContainsKey(itemID))
+ string type = m_taskInventory[itemID].inv_type;
+ m_taskInventory.Remove(itemID);
+ m_inventorySerial++;
+ if (type == "lsltext")
+ {
+ return 10;
+ }
+ else
{
- string type = m_taskInventory[itemID].inv_type;
- m_taskInventory.Remove(itemID);
- m_inventorySerial++;
- if (type == "lsltext")
- {
- return 10;
- }
- else
- {
- return 0;
- }
+ return 0;
}
}
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ itemID, Name, UUID);
+ }
+
return -1;
}
--
cgit v1.1