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);
}
/// <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)
{
m_log.DebugFormat(
"[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}",
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);
}

View File

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

View File

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

View File

@ -141,8 +141,11 @@ namespace OpenSim.Services.Interfaces
/// <summary>
/// Add a new item to the user's inventory
/// </summary>
/// <param name="item"></param>
/// <returns>true if the item was successfully added</returns>
/// <param name="item">
/// 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);
/// <summary>

View File

@ -219,12 +219,21 @@ namespace OpenSim.Services.InventoryService
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(
new string[] { "agentID", "type"},
new string[] { principalID.ToString(), ((int)type).ToString() });
if (folders.Length == 0)
{
// m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID);
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]);
}
@ -235,7 +244,7 @@ namespace OpenSim.Services.InventoryService
// connector. So we disregard the principal and look
// 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();
inventory.UserID = principalID;
inventory.Folders = new List<InventoryFolderBase>();
@ -354,6 +363,9 @@ namespace OpenSim.Services.InventoryService
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));
}