From dfe5e9d4ebb705d0c20d6260bae5d11659ac904d Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 7 Apr 2008 01:46:00 +0000
Subject: * EXPERIMENTAL ROUGH DRAFT: First rough implementation of avatar to
avatar item giving * Now you can drag an object from your inventory and give
it to another avatar * !!! Use at your own risk !!! Many things are
unimplemented as of yet, including permissions (the person receiving your
item can probably do absolutely everything with it) * Also, items for the
receiving end up in their root folder rather than the objects folder
---
.../Region/Environment/Scenes/Scene.Inventory.cs | 87 +++++++++++++++++++++-
1 file changed, 83 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 2b8f344..f6f1367 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -286,10 +286,89 @@ namespace OpenSim.Region.Environment.Scenes
"[AGENT INVENTORY]: Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
}
}
+
+ ///
+ /// Give an inventory item from one avatar to another
+ ///
+ ///
+ ///
+ ///
+ public void GiveInventoryItem(IClientAPI recipientClient, LLUUID senderId, LLUUID itemId)
+ {
+ // Retrieve the item from the sender
+ CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId);
+
+ if (senderUserInfo == null)
+ {
+ m_log.ErrorFormat(
+ "[AGENT INVENTORY]: Failed to find sending user {0} for item {1}", senderId, itemId);
+
+ return;
+ }
+
+ if (senderUserInfo.RootFolder != null)
+ {
+ InventoryItemBase item = senderUserInfo.RootFolder.HasItem(itemId);
+ if (item != null)
+ {
+ // TODO get recipient's root folder
+ CachedUserInfo recipientUserInfo
+ = CommsManager.UserProfileCacheService.GetUserDetails(recipientClient.AgentId);
+
+ if (recipientUserInfo != null)
+ {
+ // Insert a copy of the item into the recipient
+ InventoryItemBase itemCopy = new InventoryItemBase();
+ itemCopy.avatarID = recipientClient.AgentId;
+ itemCopy.creatorsID = recipientClient.AgentId;
+ itemCopy.inventoryID = LLUUID.Random();
+ itemCopy.assetID = item.assetID;
+ itemCopy.inventoryDescription = item.inventoryDescription;
+ itemCopy.inventoryName = item.inventoryName;
+ itemCopy.assetType = item.assetType;
+ itemCopy.invType = item.invType;
+ itemCopy.parentFolderID = recipientUserInfo.RootFolder.folderID;
+ itemCopy.inventoryCurrentPermissions = 2147483647;
+ itemCopy.inventoryNextPermissions = 2147483647;
+ itemCopy.inventoryEveryOnePermissions = item.inventoryEveryOnePermissions;
+ itemCopy.inventoryBasePermissions = item.inventoryBasePermissions;
+ itemCopy.inventoryCurrentPermissions = item.inventoryCurrentPermissions;
+
+ recipientUserInfo.AddItem(recipientClient.AgentId, itemCopy);
+
+ // Let the recipient client know about this new item
+ recipientClient.SendBulkUpdateInventory(itemCopy);
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "[AGENT INVENTORY]: Could not find userinfo for recipient user {0}, {1} of item {2}, {3} from {4}",
+ recipientClient.Name, recipientClient.AgentId, item.inventoryName,
+ item.inventoryID, senderId);
+ }
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "[AGENT INVENTORY]: Failed to find item {0} to give to {1}", itemId, senderId);
+
+ return;
+ }
+ }
+ else
+ {
+ m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder");
+ return;
+ }
+ }
public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID,
LLUUID newFolderID, string newName)
{
+ m_log.DebugFormat(
+ "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
+ remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
+
InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID);
if (item == null)
{
@@ -349,9 +428,8 @@ namespace OpenSim.Region.Environment.Scenes
public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length,
string newName)
{
- m_log.Info(
- "[AGENT INVENTORY]: " +
- "Moving item for " + remoteClient.AgentId.ToString());
+ m_log.DebugFormat(
+ "[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo == null)
@@ -429,7 +507,8 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// Create a new inventory item.
+ /// Create a new inventory item. Called when the client creates a new item directly within their
+ /// inventory (e.g. by selecting a context inventory menu option).
///
///
///
--
cgit v1.1