Fix bug in llGiveInventory() where items were disappearing on relog

This was a regression - the code to look up the correct type folder was no longer being called if items were added without a parent folder set
This may have been broken since commit bd49985a on 2010-05-02
prebuild-update
Justin Clark-Casey (justincc) 2010-08-23 23:16:48 +01:00
parent 74e5fe5aa9
commit 704a53fb9b
5 changed files with 38 additions and 16 deletions

View File

@ -216,16 +216,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return m_InventoryService.PurgeFolder(folder); return m_InventoryService.PurgeFolder(folder);
} }
/// <summary>
/// Add a new item to the user's inventory
/// </summary>
/// <param name="item"></param>
/// <returns>true if the item was successfully added</returns>
public bool AddItem(InventoryItemBase item) public bool AddItem(InventoryItemBase item)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}", "[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}",
item.Name, item.Owner, item.Folder); item.Name, item.Owner, item.Folder);
if (UUID.Zero == item.Folder)
{
InventoryFolderBase f = m_InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType);
if (f != null)
{
item.Folder = f.ID;
}
else
{
f = m_InventoryService.GetRootFolder(item.Owner);
if (f != null)
item.Folder = f.ID;
else
return false;
}
}
return m_InventoryService.AddItem(item); return m_InventoryService.AddItem(item);
} }

View File

@ -294,9 +294,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return m_RemoteConnector.GetAssetPermissions(userID, assetID); return m_RemoteConnector.GetAssetPermissions(userID, assetID);
} }
#endregion #endregion
} }
} }

View File

@ -3844,18 +3844,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (World.GetScenePresence(destId) != null) if (World.GetScenePresence(destId) != null)
{ {
// destination is an avatar // destination is an avatar
InventoryItemBase agentItem = InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
if (agentItem == null) if (agentItem == null)
return; return;
byte[] bucket = new byte[17]; byte[] bucket = new byte[17];
bucket[0] = (byte)assetType; bucket[0] = (byte)assetType;
byte[] objBytes = objId.GetBytes(); byte[] objBytes = agentItem.ID.GetBytes();
Array.Copy(objBytes, 0, bucket, 1, 16); Array.Copy(objBytes, 0, bucket, 1, 16);
Console.WriteLine("Giving inventory");
GridInstantMessage msg = new GridInstantMessage(World, GridInstantMessage msg = new GridInstantMessage(World,
m_host.UUID, m_host.Name+", an object owned by "+ m_host.UUID, m_host.Name+", an object owned by "+
resolveName(m_host.OwnerID)+",", destId, resolveName(m_host.OwnerID)+",", destId,

View File

@ -141,8 +141,11 @@ namespace OpenSim.Services.Interfaces
/// <summary> /// <summary>
/// Add a new item to the user's inventory /// Add a new item to the user's inventory
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item">
/// <returns>true if the item was successfully added</returns> /// The item to be added. If item.FolderID == UUID.Zero then the item is added to the most suitable system
/// folder. If there is no suitable folder then the item is added to the user's root inventory folder.
/// </param>
/// <returns>true if the item was successfully added, false if it was not</returns>
bool AddItem(InventoryItemBase item); bool AddItem(InventoryItemBase item);
/// <summary> /// <summary>

View File

@ -219,12 +219,21 @@ namespace OpenSim.Services.InventoryService
public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
{ {
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
XInventoryFolder[] folders = m_Database.GetFolders( XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "agentID", "type"}, new string[] { "agentID", "type"},
new string[] { principalID.ToString(), ((int)type).ToString() }); new string[] { principalID.ToString(), ((int)type).ToString() });
if (folders.Length == 0) if (folders.Length == 0)
{
// m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID);
return null; return null;
}
// m_log.DebugFormat(
// "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}",
// folders[0].folderName, folders[0].folderID, type, principalID);
return ConvertToOpenSim(folders[0]); return ConvertToOpenSim(folders[0]);
} }
@ -235,7 +244,7 @@ namespace OpenSim.Services.InventoryService
// connector. So we disregard the principal and look // connector. So we disregard the principal and look
// by ID. // by ID.
// //
m_log.DebugFormat("[XINVENTORY]: Fetch contents for folder {0}", folderID.ToString()); m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString());
InventoryCollection inventory = new InventoryCollection(); InventoryCollection inventory = new InventoryCollection();
inventory.UserID = principalID; inventory.UserID = principalID;
inventory.Folders = new List<InventoryFolderBase>(); inventory.Folders = new List<InventoryFolderBase>();
@ -354,6 +363,9 @@ namespace OpenSim.Services.InventoryService
public virtual bool AddItem(InventoryItemBase item) public virtual bool AddItem(InventoryItemBase item)
{ {
// m_log.DebugFormat(
// "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner);
return m_Database.StoreItem(ConvertFromOpenSim(item)); return m_Database.StoreItem(ConvertFromOpenSim(item));
} }