Mantis#5189. Thank you kindly, Matth for your patch

to add the beginnings of llGiveInventory().
0.6.0-stable
Charles Krinke 2008-06-24 21:23:28 +00:00
parent 6b7930104b
commit dc0d089bf5
2 changed files with 139 additions and 14 deletions

View File

@ -869,21 +869,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="primLocalID"></param>
/// <param name="part"></param>
/// <param name="itemID"></param>
public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, SceneObjectPart part, LLUUID itemId)
{
SceneObjectPart part = GetSceneObjectPart(primLocalId);
if (null == part)
{
m_log.WarnFormat(
"[PRIM INVENTORY]: " +
"Move of inventory item {0} from prim with local id {1} failed because the prim could not be found",
itemId, primLocalId);
return;
}
TaskInventoryItem taskItem = part.GetInventoryItem(itemId);
@ -935,6 +924,105 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
/// <see>MoveTaskInventoryItem</see>
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="primLocalID"></param>
/// <param name="itemID"></param>
public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
{
SceneObjectPart part = GetSceneObjectPart(primLocalId);
if (null == part)
{
m_log.WarnFormat(
"[PRIM INVENTORY]: " +
"Move of inventory item {0} from prim with local id {1} failed because the prim could not be found",
itemId, primLocalId);
return;
}
MoveTaskInventoryItem(remoteClient, folderId, part, itemId);
}
/// <summary>
/// <see>MoveTaskInventoryItem</see>
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="part"></param>
/// <param name="itemID"></param>
public void MoveTaskInventoryItem(LLUUID avatarId, LLUUID folderId, SceneObjectPart part, LLUUID itemId)
{
ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar))
{
MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Avatar {0} cannot be found to update its prim item asset",
avatarId);
}
}
/// <summary>
/// Copy a task (prim) inventory item to another task (prim)
/// </summary>
/// <param name="destId"></param>
/// <param name="part"></param>
/// <param name="itemId"></param>
public void CopyTaskInventoryItem(LLUUID destId, SceneObjectPart part, LLUUID itemId)
{
TaskInventoryItem srcTaskItem = part.GetInventoryItem(itemId);
if(srcTaskItem == null)
{
// error was already logged
return;
}
SceneObjectPart destPart = GetSceneObjectPart(destId);
if(destPart == null)
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Could not find prim for ID {0}",
destId);
return;
}
TaskInventoryItem destTaskItem = new TaskInventoryItem();
destTaskItem.ItemID = LLUUID.Random();
destTaskItem.CreatorID = srcTaskItem.CreatorID;
destTaskItem.AssetID = srcTaskItem.AssetID;
destTaskItem.GroupID = srcTaskItem.GroupID;
destTaskItem.OwnerID = srcTaskItem.OwnerID;
destTaskItem.ParentID = srcTaskItem.ParentID;
destTaskItem.ParentPartID = srcTaskItem.ParentPartID;
destTaskItem.BaseMask = srcTaskItem.BaseMask;
destTaskItem.EveryoneMask = srcTaskItem.EveryoneMask;
destTaskItem.GroupMask = srcTaskItem.GroupMask;
destTaskItem.OwnerMask = srcTaskItem.OwnerMask;
destTaskItem.Flags = srcTaskItem.Flags;
destTaskItem.Description = srcTaskItem.Description;
destTaskItem.Name = srcTaskItem.Name;
destTaskItem.InvType = srcTaskItem.InvType;
destTaskItem.Type = srcTaskItem.Type;
destPart.AddInventoryItem(destTaskItem);
}
/// <summary>
/// Update an item in a prim (task) inventory.
/// This method does not handle scripts, <see>RezScript(IClientAPI, LLUUID, unit)</see>

View File

@ -35,6 +35,7 @@ using Nini.Config;
using Axiom.Math;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
@ -2696,7 +2697,43 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llGiveInventory(string destination, string inventory)
{
m_host.AddScriptLPS(1);
NotImplemented("llGiveInventory not yet oh no!");
bool found = false;
LLUUID destId = LLUUID.Zero;
LLUUID objId = LLUUID.Zero;
if(!LLUUID.TryParse(destination, out destId))
{
llSay(0, "Could not parse key " + destination);
return;
}
// move the first object found with this inventory name
foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == inventory)
{
found = true;
objId = inv.Key;
break;
}
}
// check if destination is an avatar
if (World.GetScenePresence(destId) != null)
{
// destination is an avatar
CachedUserInfo userInfo =
World.CommsManager.UserProfileCacheService.GetUserDetails(destId);
World.MoveTaskInventoryItem(destId,userInfo.RootFolder.ID, m_host, objId);
}
else
{
// destination is an object
World.CopyTaskInventoryItem(destId, m_host, objId);
}
if (!found)
llSay(0, "Could not find object " + inventory);
}
public void llRemoveInventory(string item)