* minor: documentation in SceneObjectPart.Inventory.cs. Refactor AddInventoryItem methods to reduce code duplication
parent
666626db6d
commit
1b69714c44
|
@ -1408,7 +1408,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
destPart.AddInventoryItemExclusive(destTaskItem);
|
destPart.AddInventoryItemExclusive(destTaskItem);
|
||||||
|
|
||||||
if ( running > 0 )
|
if (running > 0)
|
||||||
{
|
{
|
||||||
if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID))
|
if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID))
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,6 +90,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Change every item in this prim's inventory to a new owner.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
public void ChangeInventoryOwner(LLUUID ownerId)
|
public void ChangeInventoryOwner(LLUUID ownerId)
|
||||||
{
|
{
|
||||||
lock (TaskInventory)
|
lock (TaskInventory)
|
||||||
|
@ -122,8 +126,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||||
{
|
{
|
||||||
// XXX more hardcoding badness. Should be an enum in TaskInventoryItem
|
if ((int)InventoryType.LSL == item.InvType)
|
||||||
if (10 == item.Type)
|
|
||||||
{
|
{
|
||||||
CreateScriptInstance(item, startParam, postOnRez);
|
CreateScriptInstance(item, startParam, postOnRez);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +143,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||||
{
|
{
|
||||||
if (10 == item.Type)
|
if ((int)InventoryType.LSL == item.InvType)
|
||||||
{
|
{
|
||||||
RemoveScriptInstance(item.ItemID);
|
RemoveScriptInstance(item.ItemID);
|
||||||
RemoveScriptEvents(item.ItemID);
|
RemoveScriptEvents(item.ItemID);
|
||||||
|
@ -154,7 +157,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
||||||
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez)
|
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez)
|
||||||
{
|
{
|
||||||
// m_log.InfoFormat(
|
// m_log.InfoFormat(
|
||||||
|
@ -200,7 +202,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (m_taskInventory.ContainsKey(itemId))
|
if (m_taskInventory.ContainsKey(itemId))
|
||||||
{
|
{
|
||||||
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez);
|
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -232,7 +233,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assumes a lock is held on the inventory
|
/// <summary>
|
||||||
|
/// Check if the inventory holds an item with a given name.
|
||||||
|
/// This method assumes that the task inventory is already locked.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private bool InventoryContainsName(string name)
|
private bool InventoryContainsName(string name)
|
||||||
{
|
{
|
||||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||||
|
@ -243,6 +249,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For a given item name, return that name if it is available. Otherwise, return the next available
|
||||||
|
/// similar name (which is currently the original name with the next available numeric suffix).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private string FindAvailableInventoryName(string name)
|
private string FindAvailableInventoryName(string name)
|
||||||
{
|
{
|
||||||
if (!InventoryContainsName(name))
|
if (!InventoryContainsName(name))
|
||||||
|
@ -260,49 +272,54 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an item to this prim's inventory.
|
/// Add an item to this prim's inventory. If an item with the same name already exists, then an alternative
|
||||||
|
/// name is chosen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
public void AddInventoryItem(TaskInventoryItem item)
|
public void AddInventoryItem(TaskInventoryItem item)
|
||||||
{
|
{
|
||||||
item.ParentID = UUID;
|
|
||||||
item.ParentPartID = UUID;
|
|
||||||
|
|
||||||
string name = FindAvailableInventoryName(item.Name);
|
string name = FindAvailableInventoryName(item.Name);
|
||||||
if (name == String.Empty)
|
if (name == String.Empty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
item.Name=name;
|
AddInventoryItem(name, item);
|
||||||
|
|
||||||
lock (m_taskInventory)
|
|
||||||
{
|
|
||||||
m_taskInventory.Add(item.ItemID, item);
|
|
||||||
TriggerScriptChangedEvent(Changed.INVENTORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_inventorySerial++;
|
|
||||||
//m_inventorySerial += 2;
|
|
||||||
HasInventoryChanged = true;
|
|
||||||
ParentGroup.HasGroupChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an item to this prim's inventory. If an item with the same name already exists, it is replaced.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
public void AddInventoryItemExclusive(TaskInventoryItem item)
|
public void AddInventoryItemExclusive(TaskInventoryItem item)
|
||||||
{
|
{
|
||||||
item.ParentID = UUID;
|
|
||||||
item.ParentPartID = UUID;
|
|
||||||
|
|
||||||
List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values);
|
List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values);
|
||||||
foreach(TaskInventoryItem i in il)
|
foreach(TaskInventoryItem i in il)
|
||||||
{
|
{
|
||||||
if(i.Name == item.Name)
|
if (i.Name == item.Name)
|
||||||
{
|
{
|
||||||
if(i.Type == 10)
|
if (i.InvType == (int)InventoryType.LSL)
|
||||||
RemoveScriptInstance(i.ItemID);
|
RemoveScriptInstance(i.ItemID);
|
||||||
|
|
||||||
RemoveInventoryItem(i.ItemID);
|
RemoveInventoryItem(i.ItemID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddInventoryItem(item.Name, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an item to this prim's inventory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name that the new item should have.</param>
|
||||||
|
/// <param name="item">
|
||||||
|
/// The item itself. The name within this structure is ignored in favour of the name
|
||||||
|
/// given in this method's arguments
|
||||||
|
/// </param>
|
||||||
|
protected void AddInventoryItem(string name, TaskInventoryItem item)
|
||||||
|
{
|
||||||
|
item.ParentID = UUID;
|
||||||
|
item.ParentPartID = UUID;
|
||||||
|
|
||||||
lock (m_taskInventory)
|
lock (m_taskInventory)
|
||||||
{
|
{
|
||||||
m_taskInventory.Add(item.ItemID, item);
|
m_taskInventory.Add(item.ItemID, item);
|
||||||
|
|
Loading…
Reference in New Issue