diff options
author | Oren Hurvitz | 2013-07-15 15:26:18 +0300 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-09-26 20:09:43 +0100 |
commit | 5be6954e5dc6258cc7f20fc802411569cfe40b17 (patch) | |
tree | 479cb8a11c60a1f76ee6634de8a7a8100d8ceb3c /OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |
parent | minor: Add prefix to log message in LureModule (diff) | |
download | opensim-SC_OLD-5be6954e5dc6258cc7f20fc802411569cfe40b17.zip opensim-SC_OLD-5be6954e5dc6258cc7f20fc802411569cfe40b17.tar.gz opensim-SC_OLD-5be6954e5dc6258cc7f20fc802411569cfe40b17.tar.bz2 opensim-SC_OLD-5be6954e5dc6258cc7f20fc802411569cfe40b17.tar.xz |
When giving items between avatars in different simulators, only add the item to the receiving avatar's inventory once.
When a user gives an item, the user's client sends an InventoryOffered IM message to its simulator. This adds the item to the receiver's inventory. If the receiver isn't in the same simulator then XMLRPC is used to forward the IM to the correct simulator. The bug was that the receiving simulator handled the message by calling OnInstantMessage() again, which added a second copy of the item to the inventory. Instead, the receiving simulator should only notify the avatar that the item was offered.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 1417a19..f52654f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -148,9 +148,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
148 | 148 | ||
149 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 149 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
150 | { | 150 | { |
151 | // m_log.DebugFormat( | 151 | m_log.DebugFormat( |
152 | // "[INVENTORY TRANSFER]: {0} IM type received from {1}", | 152 | "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}", |
153 | // (InstantMessageDialog)im.dialog, client.Name); | 153 | (InstantMessageDialog)im.dialog, client.Name, |
154 | im.fromAgentID, im.fromAgentName, im.toAgentID); | ||
154 | 155 | ||
155 | Scene scene = FindClientScene(client.AgentId); | 156 | Scene scene = FindClientScene(client.AgentId); |
156 | 157 | ||
@@ -450,23 +451,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
450 | /// <summary> | 451 | /// <summary> |
451 | /// | 452 | /// |
452 | /// </summary> | 453 | /// </summary> |
453 | /// <param name="msg"></param> | 454 | /// <param name="im"></param> |
454 | private void OnGridInstantMessage(GridInstantMessage msg) | 455 | private void OnGridInstantMessage(GridInstantMessage im) |
455 | { | 456 | { |
457 | // Check if it's a type of message that we should handle | ||
458 | if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
459 | || (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | ||
460 | || (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) | ||
461 | || (im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined))) | ||
462 | return; | ||
463 | |||
464 | m_log.DebugFormat( | ||
465 | "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}", | ||
466 | (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID); | ||
467 | |||
456 | // Check if this is ours to handle | 468 | // Check if this is ours to handle |
457 | // | 469 | // |
458 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | 470 | Scene scene = FindClientScene(new UUID(im.toAgentID)); |
459 | 471 | ||
460 | if (scene == null) | 472 | if (scene == null) |
461 | return; | 473 | return; |
462 | 474 | ||
463 | // Find agent to deliver to | 475 | // Find agent to deliver to |
464 | // | 476 | // |
465 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 477 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
466 | 478 | ||
467 | // Just forward to local handling | 479 | if (user != null) |
468 | OnInstantMessage(user.ControllingClient, msg); | 480 | { |
481 | user.ControllingClient.SendInstantMessage(im); | ||
469 | 482 | ||
483 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) | ||
484 | { | ||
485 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
486 | UUID inventoryID = new UUID(im.binaryBucket, 1); | ||
487 | |||
488 | IInventoryService invService = scene.InventoryService; | ||
489 | InventoryNodeBase node = null; | ||
490 | if (AssetType.Folder == assetType) | ||
491 | { | ||
492 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, new UUID(im.toAgentID)); | ||
493 | node = invService.GetFolder(folder); | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | InventoryItemBase item = new InventoryItemBase(inventoryID, new UUID(im.toAgentID)); | ||
498 | node = invService.GetItem(item); | ||
499 | } | ||
500 | |||
501 | if (node != null) | ||
502 | user.ControllingClient.SendBulkUpdateInventory(node); | ||
503 | } | ||
504 | } | ||
470 | } | 505 | } |
471 | } | 506 | } |
472 | } | 507 | } |