* refactor: Rip out SOP inventory from the partial into a separate class

* SceneObjectPartInventory.cs isn't a particularly good name but it's probably not got a long life
* A proper inventory interface to follow
* Parallel changes for other inventory partial classes to follow at a later date
0.6.1-post-fixes
Justin Clarke Casey 2008-11-21 21:16:42 +00:00
parent 02105c9c2a
commit 915593bfbc
23 changed files with 252 additions and 199 deletions

View File

@ -718,7 +718,7 @@ VALUES
//m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID);
} }
prim.RestoreInventoryItems(inventory); prim.Inventory.RestoreInventoryItems(inventory);
// XXX A nasty little hack to recover the folder id for the prim (which is currently stored in // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
// every item). This data should really be stored in the prim table itself. // every item). This data should really be stored in the prim table itself.

View File

@ -511,7 +511,7 @@ namespace OpenSim.Data.MySQL
//m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID);
} }
prim.RestoreInventoryItems(inventory); prim.Inventory.RestoreInventoryItems(inventory);
// XXX A nasty little hack to recover the folder id for the prim (which is currently stored in // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
// every item). This data should really be stored in the prim table itself. // every item). This data should really be stored in the prim table itself.

View File

@ -261,7 +261,7 @@ namespace OpenSim.Data.NHibernate
} }
if (inventory.Count > 0) if (inventory.Count > 0)
p.RestoreInventoryItems(inventory); p.Inventory.RestoreInventoryItems(inventory);
} }
foreach (SceneObjectGroup g in SOG.Values) foreach (SceneObjectGroup g in SOG.Values)
{ {

View File

@ -514,7 +514,7 @@ namespace OpenSim.Data.SQLite
//m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID);
} }
prim.RestoreInventoryItems(inventory); prim.Inventory.RestoreInventoryItems(inventory);
// XXX A nasty little hack to recover the folder id for the prim (which is currently stored in // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
// every item). This data should really be stored in the prim table itself. // every item). This data should really be stored in the prim table itself.

View File

@ -255,8 +255,8 @@ namespace OpenSim.Data.Tests
sop.GroupPosition = groupos; sop.GroupPosition = groupos;
sop.RotationOffset = rotoff; sop.RotationOffset = rotoff;
sop.CreatorID = creator; sop.CreatorID = creator;
sop.InventorySerial = iserial; sop.Inventory.Serial = iserial;
sop.TaskInventory = dic; sop.Inventory.Items = dic;
sop.ObjectFlags = objf; sop.ObjectFlags = objf;
sop.Name = name; sop.Name = name;
sop.Material = material; sop.Material = material;
@ -287,8 +287,8 @@ namespace OpenSim.Data.Tests
Assert.That(rotoff,Is.EqualTo(sop.RotationOffset)); Assert.That(rotoff,Is.EqualTo(sop.RotationOffset));
Assert.That(uuid,Is.EqualTo(sop.UUID)); Assert.That(uuid,Is.EqualTo(sop.UUID));
Assert.That(creator,Is.EqualTo(sop.CreatorID)); Assert.That(creator,Is.EqualTo(sop.CreatorID));
Assert.That(iserial,Is.EqualTo(sop.InventorySerial)); Assert.That(iserial,Is.EqualTo(sop.Inventory.Serial));
Assert.That(dic,Is.EqualTo(sop.TaskInventory)); Assert.That(dic,Is.EqualTo(sop.Inventory.Items));
Assert.That(objf,Is.EqualTo(sop.ObjectFlags)); Assert.That(objf,Is.EqualTo(sop.ObjectFlags));
Assert.That(name,Is.EqualTo(sop.Name)); Assert.That(name,Is.EqualTo(sop.Name));
Assert.That(material,Is.EqualTo(sop.Material)); Assert.That(material,Is.EqualTo(sop.Material));
@ -337,7 +337,7 @@ namespace OpenSim.Data.Tests
Assert.That(uuid,Is.EqualTo(p.UUID)); Assert.That(uuid,Is.EqualTo(p.UUID));
Assert.That(creator,Is.EqualTo(p.CreatorID)); Assert.That(creator,Is.EqualTo(p.CreatorID));
//Assert.That(iserial,Is.EqualTo(p.InventorySerial)); //Assert.That(iserial,Is.EqualTo(p.InventorySerial));
Assert.That(dic,Is.EqualTo(p.TaskInventory)); Assert.That(dic,Is.EqualTo(p.Inventory.Items));
//Assert.That(objf,Is.EqualTo(p.ObjectFlags)); //Assert.That(objf,Is.EqualTo(p.ObjectFlags));
Assert.That(name,Is.EqualTo(p.Name)); Assert.That(name,Is.EqualTo(p.Name));
Assert.That(material,Is.EqualTo(p.Material)); Assert.That(material,Is.EqualTo(p.Material));
@ -415,7 +415,7 @@ namespace OpenSim.Data.Tests
sog2.RootPart.GroupPosition = groupos; sog2.RootPart.GroupPosition = groupos;
sog2.RootPart.RotationOffset = rotoff; sog2.RootPart.RotationOffset = rotoff;
sog2.RootPart.CreatorID = creator; sog2.RootPart.CreatorID = creator;
sog2.RootPart.TaskInventory = dic; sog2.RootPart.Inventory.Items = dic;
sog2.RootPart.Name = name; sog2.RootPart.Name = name;
sog2.RootPart.Material = material; sog2.RootPart.Material = material;
sog2.RootPart.ScriptAccessPin = pin; sog2.RootPart.ScriptAccessPin = pin;
@ -449,7 +449,7 @@ namespace OpenSim.Data.Tests
Assert.That(name,Is.EqualTo(p.Name)); Assert.That(name,Is.EqualTo(p.Name));
Assert.That(rotoff,Is.EqualTo(p.RotationOffset)); Assert.That(rotoff,Is.EqualTo(p.RotationOffset));
Assert.That(creator,Is.EqualTo(p.CreatorID)); Assert.That(creator,Is.EqualTo(p.CreatorID));
Assert.That(dic,Is.EqualTo(p.TaskInventory)); Assert.That(dic,Is.EqualTo(p.Inventory.Items));
Assert.That(name,Is.EqualTo(p.Name)); Assert.That(name,Is.EqualTo(p.Name));
Assert.That(material,Is.EqualTo(p.Material)); Assert.That(material,Is.EqualTo(p.Material));
Assert.That(pin,Is.EqualTo(p.ScriptAccessPin)); Assert.That(pin,Is.EqualTo(p.ScriptAccessPin));
@ -534,7 +534,7 @@ namespace OpenSim.Data.Tests
// TODO: seriously??? this is the way we need to loop to get this? // TODO: seriously??? this is the way we need to loop to get this?
List<TaskInventoryItem> list = new List<TaskInventoryItem>(); List<TaskInventoryItem> list = new List<TaskInventoryItem>();
foreach (UUID uuid in sog.RootPart.GetInventoryList()) foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
{ {
list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid)); list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
} }

View File

@ -4998,7 +4998,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
break; break;
TaskInventoryItem ti = part.GetInventoryItem(itemID); TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
if (ti == null) if (ti == null)
break; break;

View File

@ -267,7 +267,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset); m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset);
if (part.UpdateInventoryItem(item)) if (part.Inventory.UpdateInventoryItem(item))
part.GetProperties(remoteClient); part.GetProperties(remoteClient);
} }

View File

@ -796,7 +796,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return false; return false;
TaskInventoryItem ti = part.GetInventoryItem(notecard); TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
if (ti == null) if (ti == null)
return false; return false;
@ -1188,7 +1188,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return false; return false;
TaskInventoryItem ti = part.GetInventoryItem(script); TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
if (ti == null) if (ti == null)
return false; return false;
@ -1266,7 +1266,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
return false; return false;
TaskInventoryItem ti = part.GetInventoryItem(notecard); TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
if (ti == null) if (ti == null)
return false; return false;

View File

@ -280,7 +280,7 @@ namespace OpenSim.Region.Environment.Scenes
if (isScriptRunning) if (isScriptRunning)
{ {
part.RemoveScriptInstance(item.ItemID); part.Inventory.RemoveScriptInstance(item.ItemID);
} }
// Update item with new asset // Update item with new asset
item.AssetID = asset.FullID; item.AssetID = asset.FullID;
@ -292,7 +292,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
// Needs to determine which engine was running it and use that // Needs to determine which engine was running it and use that
// //
part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0);
} }
else else
{ {
@ -945,7 +945,7 @@ namespace OpenSim.Region.Environment.Scenes
private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId)
{ {
TaskInventoryItem taskItem = part.GetInventoryItem(itemId); TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId);
if (null == taskItem) if (null == taskItem)
{ {
@ -995,7 +995,7 @@ namespace OpenSim.Region.Environment.Scenes
if (!ExternalChecks.ExternalChecksBypassPermissions()) if (!ExternalChecks.ExternalChecksBypassPermissions())
{ {
if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
part.RemoveInventoryItem(itemId); part.Inventory.RemoveInventoryItem(itemId);
} }
return agentItem; return agentItem;
@ -1040,7 +1040,7 @@ namespace OpenSim.Region.Environment.Scenes
return; return;
} }
TaskInventoryItem taskItem = part.GetInventoryItem(itemId); TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId);
if (null == taskItem) if (null == taskItem)
{ {
@ -1104,7 +1104,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="itemId"></param> /// <param name="itemId"></param>
public void MoveTaskInventoryItem(UUID destId, SceneObjectPart part, UUID itemId) public void MoveTaskInventoryItem(UUID destId, SceneObjectPart part, UUID itemId)
{ {
TaskInventoryItem srcTaskItem = part.GetInventoryItem(itemId); TaskInventoryItem srcTaskItem = part.Inventory.GetInventoryItem(itemId);
if (srcTaskItem == null) if (srcTaskItem == null)
{ {
@ -1184,10 +1184,10 @@ namespace OpenSim.Region.Environment.Scenes
destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.InvType = srcTaskItem.InvType;
destTaskItem.Type = srcTaskItem.Type; destTaskItem.Type = srcTaskItem.Type;
destPart.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID); destPart.Inventory.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID);
if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
part.RemoveInventoryItem(itemId); part.Inventory.RemoveInventoryItem(itemId);
ScenePresence avatar; ScenePresence avatar;
@ -1254,7 +1254,7 @@ namespace OpenSim.Region.Environment.Scenes
if (part != null) if (part != null)
{ {
TaskInventoryItem currentItem = part.GetInventoryItem(itemID); TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID);
bool allowInventoryDrop = (part.GetEffectiveObjectFlags() bool allowInventoryDrop = (part.GetEffectiveObjectFlags()
& (uint)PrimFlags.AllowInventoryDrop) != 0; & (uint)PrimFlags.AllowInventoryDrop) != 0;
@ -1314,7 +1314,7 @@ namespace OpenSim.Region.Environment.Scenes
agentTransactions.HandleTaskItemUpdateFromTransaction( agentTransactions.HandleTaskItemUpdateFromTransaction(
remoteClient, part, transactionID, currentItem); remoteClient, part, transactionID, currentItem);
} }
if (part.UpdateInventoryItem(itemInfo)) if (part.Inventory.UpdateInventoryItem(itemInfo))
part.GetProperties(remoteClient); part.GetProperties(remoteClient);
} }
} }
@ -1364,7 +1364,7 @@ namespace OpenSim.Region.Environment.Scenes
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
// TODO: switch to posting on_rez here when scripts // TODO: switch to posting on_rez here when scripts
// have state in inventory // have state in inventory
part.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
// m_log.InfoFormat("[PRIMINVENTORY]: " + // m_log.InfoFormat("[PRIMINVENTORY]: " +
// "Rezzed script {0} into prim local ID {1} for user {2}", // "Rezzed script {0} into prim local ID {1} for user {2}",
@ -1430,10 +1430,10 @@ namespace OpenSim.Region.Environment.Scenes
taskItem.PermsMask = 0; taskItem.PermsMask = 0;
taskItem.AssetID = asset.FullID; taskItem.AssetID = asset.FullID;
part.AddInventoryItem(taskItem, false); part.Inventory.AddInventoryItem(taskItem, false);
part.GetProperties(remoteClient); part.GetProperties(remoteClient);
part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
} }
} }
@ -1445,7 +1445,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param> /// <param name="localID"></param>
public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param) public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param)
{ {
TaskInventoryItem srcTaskItem = srcPart.GetInventoryItem(srcId); TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId);
if (srcTaskItem == null) if (srcTaskItem == null)
{ {
@ -1525,11 +1525,11 @@ namespace OpenSim.Region.Environment.Scenes
destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.InvType = srcTaskItem.InvType;
destTaskItem.Type = srcTaskItem.Type; destTaskItem.Type = srcTaskItem.Type;
destPart.AddInventoryItemExclusive(destTaskItem, false); destPart.Inventory.AddInventoryItemExclusive(destTaskItem, false);
if (running > 0) if (running > 0)
{ {
destPart.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine, 0); destPart.Inventory.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine, 0);
} }
ScenePresence avatar; ScenePresence avatar;
@ -2064,7 +2064,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
part.LastOwnerID = part.OwnerID; part.LastOwnerID = part.OwnerID;
part.OwnerID = item.Owner; part.OwnerID = item.Owner;
part.ChangeInventoryOwner(item.Owner); part.Inventory.ChangeInventoryOwner(item.Owner);
} }
else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
{ {
@ -2178,7 +2178,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
part.LastOwnerID = part.OwnerID; part.LastOwnerID = part.OwnerID;
part.OwnerID = item.OwnerID; part.OwnerID = item.OwnerID;
part.ChangeInventoryOwner(item.OwnerID); part.Inventory.ChangeInventoryOwner(item.OwnerID);
} }
else if ((item.CurrentPermissions & 8) != 0) // Slam! else if ((item.CurrentPermissions & 8) != 0) // Slam!
{ {
@ -2200,7 +2200,7 @@ namespace OpenSim.Region.Environment.Scenes
if (!ExternalChecks.ExternalChecksBypassPermissions()) if (!ExternalChecks.ExternalChecksBypassPermissions())
{ {
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
sourcePart.RemoveInventoryItem(item.ItemID); sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
} }
return rootPart.ParentGroup; return rootPart.ParentGroup;
} }
@ -2368,7 +2368,7 @@ namespace OpenSim.Region.Environment.Scenes
if (part != null && part.ParentGroup != null) if (part != null && part.ParentGroup != null)
{ {
part.ParentGroup.SetOwnerId(ownerID); part.ParentGroup.SetOwnerId(ownerID);
part.ChangeInventoryOwner(ownerID); part.Inventory.ChangeInventoryOwner(ownerID);
part.ParentGroup.SetGroup(groupID, remoteClient); part.ParentGroup.SetGroup(groupID, remoteClient);
} }
} }

View File

@ -4277,8 +4277,8 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (SceneObjectPart child in partList) foreach (SceneObjectPart child in partList)
{ {
child.ChangeInventoryOwner(remoteClient.AgentId); child.Inventory.ChangeInventoryOwner(remoteClient.AgentId);
child.ApplyNextOwnerPermissions(); child.Inventory.ApplyNextOwnerPermissions();
} }
} }
@ -4355,13 +4355,13 @@ namespace OpenSim.Region.Environment.Scenes
break; break;
case 3: // Sell contents case 3: // Sell contents
List<UUID> invList = part.GetInventoryList(); List<UUID> invList = part.Inventory.GetInventoryList();
bool okToSell = true; bool okToSell = true;
foreach (UUID invID in invList) foreach (UUID invID in invList)
{ {
TaskInventoryItem item = part.GetInventoryItem(invID); TaskInventoryItem item = part.Inventory.GetInventoryItem(invID);
if ((item.CurrentPermissions & if ((item.CurrentPermissions &
(uint)PermissionMask.Transfer) == 0) (uint)PermissionMask.Transfer) == 0)
{ {

View File

@ -50,7 +50,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.ForceInventoryPersistence(); part.Inventory.ForceInventoryPersistence();
} }
} }
} }
@ -66,8 +66,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.CreateScriptInstances(startParam, postOnRez, engine, part.Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource);
stateSource);
} }
} }
} }
@ -81,7 +80,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.RemoveScriptInstances(); part.Inventory.RemoveScriptInstances();
} }
} }
} }
@ -96,7 +95,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
if (part != null) if (part != null)
{ {
return part.GetInventoryFileName(remoteClient, localID); return part.Inventory.GetInventoryFileName(remoteClient, localID);
} }
else else
{ {
@ -118,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
if (part != null) if (part != null)
{ {
part.RequestInventoryFile(client, xferManager); part.Inventory.RequestInventoryFile(client, xferManager);
} }
else else
{ {
@ -191,7 +190,7 @@ namespace OpenSim.Region.Environment.Scenes
addFromAllowedDrop = remoteClient.AgentId != part.OwnerID; addFromAllowedDrop = remoteClient.AgentId != part.OwnerID;
} }
part.AddInventoryItem(taskItem, addFromAllowedDrop); part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
return true; return true;
} }
@ -217,7 +216,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart part = GetChildPart(primID); SceneObjectPart part = GetChildPart(primID);
if (part != null) if (part != null)
{ {
return part.GetInventoryItem(itemID); return part.Inventory.GetInventoryItem(itemID);
} }
else else
{ {
@ -241,7 +240,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart part = GetChildPart(item.ParentPartID); SceneObjectPart part = GetChildPart(item.ParentPartID);
if (part != null) if (part != null)
{ {
part.UpdateInventoryItem(item); part.Inventory.UpdateInventoryItem(item);
return true; return true;
} }
@ -261,7 +260,7 @@ namespace OpenSim.Region.Environment.Scenes
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
if (part != null) if (part != null)
{ {
int type = part.RemoveInventoryItem(itemID); int type = part.Inventory.RemoveInventoryItem(itemID);
return type; return type;
} }
@ -280,7 +279,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
ownerMask &= part.OwnerMask; ownerMask &= part.OwnerMask;
perms &= part.MaskEffectivePermissions(); perms &= part.Inventory.MaskEffectivePermissions();
} }
if ((ownerMask & (uint)PermissionMask.Modify) == 0) if ((ownerMask & (uint)PermissionMask.Modify) == 0)
@ -303,7 +302,7 @@ namespace OpenSim.Region.Environment.Scenes
public void ApplyNextOwnerPermissions() public void ApplyNextOwnerPermissions()
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
part.ApplyNextOwnerPermissions(); part.Inventory.ApplyNextOwnerPermissions();
} }
public string GetStateSnapshot() public string GetStateSnapshot()
@ -313,13 +312,13 @@ namespace OpenSim.Region.Environment.Scenes
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
foreach (string a in part.GetScriptAssemblies()) foreach (string a in part.Inventory.GetScriptAssemblies())
{ {
if (a != "" && !assemblies.Contains(a)) if (a != "" && !assemblies.Contains(a))
assemblies.Add(a); assemblies.Add(a);
} }
foreach (KeyValuePair<UUID, string> s in part.GetScriptStates()) foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates())
{ {
states[s.Key] = s.Value; states[s.Key] = s.Value;
} }

View File

@ -1044,7 +1044,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
// part.RemoveScriptInstances(); // part.Inventory.RemoveScriptInstances();
List<ScenePresence> avatars = Scene.GetScenePresences(); List<ScenePresence> avatars = Scene.GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
@ -1251,7 +1251,7 @@ namespace OpenSim.Region.Environment.Scenes
datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);
backup_group.ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); }); backup_group.ForEachPart(delegate(SceneObjectPart part) { part.Inventory.ProcessInventoryBackup(datastore); });
backup_group = null; backup_group = null;
} }
@ -2828,7 +2828,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.SetGroup(GroupID, client); part.SetGroup(GroupID, client);
part.ChangeInventoryGroup(GroupID); part.Inventory.ChangeInventoryGroup(GroupID);
} }
HasGroupChanged = true; HasGroupChanged = true;

View File

@ -28,14 +28,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Security.Permissions; using System.Security.Permissions;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
@ -92,8 +92,10 @@ namespace OpenSim.Region.Environment.Scenes
#endregion Enumerations #endregion Enumerations
[Serializable] [Serializable]
public partial class SceneObjectPart : IScriptHost, ISerializable public class SceneObjectPart : IScriptHost, ISerializable
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region Fields #region Fields
[XmlIgnore] [XmlIgnore]
@ -141,6 +143,12 @@ namespace OpenSim.Region.Environment.Scenes
[XmlIgnore] [XmlIgnore]
public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f); public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f);
/// <summary>
/// This part's inventory
/// </summary>
[XmlIgnore]
public readonly SceneObjectPartInventory Inventory;
[XmlIgnore] [XmlIgnore]
public bool Undoing = false; public bool Undoing = false;
@ -218,6 +226,8 @@ namespace OpenSim.Region.Environment.Scenes
m_TextureAnimation = new byte[0]; m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0]; m_particleSystem = new byte[0];
Rezzed = DateTime.Now; Rezzed = DateTime.Now;
Inventory = new SceneObjectPartInventory(this);
} }
/// <summary> /// <summary>
@ -266,6 +276,8 @@ namespace OpenSim.Region.Environment.Scenes
TrimPermissions(); TrimPermissions();
//m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo()); //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
Inventory = new SceneObjectPartInventory(this);
} }
protected SceneObjectPart(SerializationInfo info, StreamingContext context) protected SceneObjectPart(SerializationInfo info, StreamingContext context)
@ -285,6 +297,8 @@ namespace OpenSim.Region.Environment.Scenes
//System.Console.WriteLine("SceneObjectPart Deserialize END"); //System.Console.WriteLine("SceneObjectPart Deserialize END");
Rezzed = DateTime.Now; Rezzed = DateTime.Now;
Inventory = new SceneObjectPartInventory(this);
} }
#endregion Constructors #endregion Constructors
@ -332,16 +346,22 @@ namespace OpenSim.Region.Environment.Scenes
set { } // Don't allow assignment, or legacy prims wil b0rk set { } // Don't allow assignment, or legacy prims wil b0rk
} }
/// <value>
/// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
/// </value>
public uint InventorySerial public uint InventorySerial
{ {
get { return m_inventorySerial; } get { return Inventory.Serial; }
set { m_inventorySerial = value; } set { Inventory.Serial = value; }
} }
/// <value>
/// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
/// </value>
public TaskInventoryDictionary TaskInventory public TaskInventoryDictionary TaskInventory
{ {
get { return m_taskInventory; } get { return Inventory.Items; }
set { m_taskInventory = value; } set { Inventory.Items = value; }
} }
public uint ObjectFlags public uint ObjectFlags
@ -1239,7 +1259,7 @@ if (m_shape != null) {
dupe._category = _category; dupe._category = _category;
dupe.m_rezzed = m_rezzed; dupe.m_rezzed = m_rezzed;
dupe.TaskInventory = (TaskInventoryDictionary)dupe.TaskInventory.Clone(); dupe.Inventory.Items = (TaskInventoryDictionary)dupe.Inventory.Items.Clone();
if (userExposed) if (userExposed)
dupe.ResetIDs(linkNum); dupe.ResetIDs(linkNum);
@ -1412,7 +1432,7 @@ if (m_shape != null) {
throw new ArgumentNullException("info"); throw new ArgumentNullException("info");
} }
info.AddValue("m_inventoryFileName", GetInventoryFileName()); info.AddValue("m_inventoryFileName", Inventory.GetInventoryFileName());
info.AddValue("m_folderID", UUID); info.AddValue("m_folderID", UUID);
info.AddValue("PhysActor", PhysActor); info.AddValue("PhysActor", PhysActor);
@ -1452,7 +1472,7 @@ if (m_shape != null) {
info.AddValue("m_updateFlag", m_updateFlag); info.AddValue("m_updateFlag", m_updateFlag);
info.AddValue("CreatorID", _creatorID.Guid); info.AddValue("CreatorID", _creatorID.Guid);
info.AddValue("m_inventorySerial", m_inventorySerial); info.AddValue("m_inventorySerial", Inventory.Serial);
info.AddValue("m_uuid", m_uuid.Guid); info.AddValue("m_uuid", m_uuid.Guid);
info.AddValue("m_localID", m_localId); info.AddValue("m_localID", m_localId);
info.AddValue("m_name", m_name); info.AddValue("m_name", m_name);
@ -1929,8 +1949,7 @@ if (m_shape != null) {
UUID = UUID.Random(); UUID = UUID.Random();
LinkNum = linkNum; LinkNum = linkNum;
LocalId = 0; LocalId = 0;
Inventory.ResetInventoryIDs();
ResetInventoryIDs();
} }
/// <summary> /// <summary>
@ -2993,7 +3012,7 @@ if (m_shape != null) {
if (god) if (god)
{ {
_baseMask = ApplyMask(_baseMask, set, mask); _baseMask = ApplyMask(_baseMask, set, mask);
ApplyGodPermissions(_baseMask); Inventory.ApplyGodPermissions(_baseMask);
} }
break; break;
@ -3394,9 +3413,19 @@ if (m_shape != null) {
RotationalVelocity, state, FromAssetID, RotationalVelocity, state, FromAssetID,
OwnerID, (int)AttachmentPoint); OwnerID, (int)AttachmentPoint);
} }
}
public void AddScriptLPS(int count)
{
m_parentGroup.AddScriptLPS(count);
} }
public void ApplyNextOwnerPermissions()
{
_baseMask &= _nextOwnerMask;
_ownerMask &= _nextOwnerMask;
_everyoneMask &= _nextOwnerMask;
Inventory.ApplyNextOwnerPermissions();
}
}
}

View File

@ -38,13 +38,18 @@ using OpenSim.Region.Environment.Scenes.Scripting;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
public partial class SceneObjectPart : IScriptHost public class SceneObjectPartInventory
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_inventoryFileName = String.Empty; private string m_inventoryFileName = String.Empty;
private int m_inventoryFileNameSerial = 0; private int m_inventoryFileNameSerial = 0;
/// <value>
/// The part to which the inventory belongs.
/// </value>
private SceneObjectPart m_part;
/// <summary> /// <summary>
/// Serial count for inventory file , used to tell if inventory has changed /// Serial count for inventory file , used to tell if inventory has changed
/// no need for this to be part of Database backup /// no need for this to be part of Database backup
@ -54,13 +59,42 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// Holds in memory prim inventory /// Holds in memory prim inventory
/// </summary> /// </summary>
protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); protected TaskInventoryDictionary m_items = new TaskInventoryDictionary();
/// <summary> /// <summary>
/// Tracks whether inventory has changed since the last persistent backup /// Tracks whether inventory has changed since the last persistent backup
/// </summary> /// </summary>
protected bool HasInventoryChanged; protected bool HasInventoryChanged;
/// <value>
/// Inventory serial number
/// </value>
public uint Serial
{
get { return m_inventorySerial; }
set { m_inventorySerial = value; }
}
/// <value>
/// Raw inventory data
/// </value>
public TaskInventoryDictionary Items
{
get { return m_items; }
set { m_items = value; }
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="part">
/// A <see cref="SceneObjectPart"/>
/// </param>
public SceneObjectPartInventory(SceneObjectPart part)
{
m_part = part;
}
/// <summary> /// <summary>
/// Force the task inventory of this prim to persist at the next update sweep /// Force the task inventory of this prim to persist at the next update sweep
/// </summary> /// </summary>
@ -78,40 +112,40 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="linkNum">Link number for the part</param> /// <param name="linkNum">Link number for the part</param>
public void ResetInventoryIDs() public void ResetInventoryIDs()
{ {
lock (TaskInventory) lock (Items)
{ {
if (0 == TaskInventory.Count) if (0 == Items.Count)
return; return;
HasInventoryChanged = true; HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true; m_part.ParentGroup.HasGroupChanged = true;
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
TaskInventory.Clear(); Items.Clear();
foreach (TaskInventoryItem item in items) foreach (TaskInventoryItem item in items)
{ {
item.ResetIDs(UUID); item.ResetIDs(m_part.UUID);
TaskInventory.Add(item.ItemID, item); Items.Add(item.ItemID, item);
} }
} }
} }
/// <summary> /// <summary>
/// Change every item in this prim's inventory to a new owner. /// Change every item in this inventory to a new owner.
/// </summary> /// </summary>
/// <param name="ownerId"></param> /// <param name="ownerId"></param>
public void ChangeInventoryOwner(UUID ownerId) public void ChangeInventoryOwner(UUID ownerId)
{ {
lock (TaskInventory) lock (Items)
{ {
if (0 == TaskInventory.Count) if (0 == Items.Count)
{ {
return; return;
} }
HasInventoryChanged = true; HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true; m_part.ParentGroup.HasGroupChanged = true;
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
foreach (TaskInventoryItem item in items) foreach (TaskInventoryItem item in items)
{ {
if (ownerId != item.OwnerID) if (ownerId != item.OwnerID)
@ -123,18 +157,22 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
/// <summary>
/// Change every item in this inventory to a new group.
/// </summary>
/// <param name="groupID"></param>
public void ChangeInventoryGroup(UUID groupID) public void ChangeInventoryGroup(UUID groupID)
{ {
lock (TaskInventory) lock (Items)
{ {
if (0 == TaskInventory.Count) if (0 == Items.Count)
{ {
return; return;
} }
HasInventoryChanged = true; HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true; m_part.ParentGroup.HasGroupChanged = true;
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
foreach (TaskInventoryItem item in items) foreach (TaskInventoryItem item in items)
{ {
if (groupID != item.GroupID) if (groupID != item.GroupID)
@ -150,9 +188,9 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
{ {
lock (m_taskInventory) lock (m_items)
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in Items.Values)
{ {
if ((int)InventoryType.LSL == item.InvType) if ((int)InventoryType.LSL == item.InvType)
{ {
@ -167,14 +205,14 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void RemoveScriptInstances() public void RemoveScriptInstances()
{ {
lock (m_taskInventory) lock (Items)
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in Items.Values)
{ {
if ((int)InventoryType.LSL == item.InvType) if ((int)InventoryType.LSL == item.InvType)
{ {
RemoveScriptInstance(item.ItemID); RemoveScriptInstance(item.ItemID);
RemoveScriptEvents(item.ItemID); m_part.RemoveScriptEvents(item.ItemID);
} }
} }
} }
@ -192,14 +230,14 @@ namespace OpenSim.Region.Environment.Scenes
// "Starting script {0}, {1} in prim {2}, {3}", // "Starting script {0}, {1} in prim {2}, {3}",
// item.Name, item.ItemID, Name, UUID); // item.Name, item.ItemID, Name, UUID);
if (!m_parentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, UUID, item.OwnerID)) if (!m_part.ParentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
return; return;
AddFlag(PrimFlags.Scripted); m_part.AddFlag(PrimFlags.Scripted);
if (!m_parentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
{ {
AssetCache cache = m_parentGroup.Scene.AssetCache; AssetCache cache = m_part.ParentGroup.Scene.AssetCache;
cache.GetAsset(item.AssetID, delegate(UUID assetID, AssetBase asset) cache.GetAsset(item.AssetID, delegate(UUID assetID, AssetBase asset)
{ {
@ -212,13 +250,13 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
m_taskInventory[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsMask = 0;
m_taskInventory[item.ItemID].PermsGranter = UUID.Zero; m_items[item.ItemID].PermsGranter = UUID.Zero;
string script = Utils.BytesToString(asset.Data); string script = Utils.BytesToString(asset.Data);
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script, m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
startParam, postOnRez, engine, stateSource); m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
m_parentGroup.AddActiveScriptCount(1); m_part.ParentGroup.AddActiveScriptCount(1);
ScheduleFullUpdate(); m_part.ScheduleFullUpdate();
} }
}, false); }, false);
} }
@ -232,18 +270,18 @@ namespace OpenSim.Region.Environment.Scenes
/// </param> /// </param>
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
{ {
lock (m_taskInventory) lock (m_items)
{ {
if (m_taskInventory.ContainsKey(itemId)) if (m_items.ContainsKey(itemId))
{ {
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine, stateSource); CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
} }
else else
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
itemId, Name, UUID); itemId, m_part.Name, m_part.UUID);
} }
} }
} }
@ -254,17 +292,17 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="itemId"></param> /// <param name="itemId"></param>
public void RemoveScriptInstance(UUID itemId) public void RemoveScriptInstance(UUID itemId)
{ {
if (m_taskInventory.ContainsKey(itemId)) if (m_items.ContainsKey(itemId))
{ {
m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalId, itemId); m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemId);
m_parentGroup.AddActiveScriptCount(-1); m_part.ParentGroup.AddActiveScriptCount(-1);
} }
else else
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}", "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2}",
itemId, Name, UUID); itemId, m_part.Name, m_part.UUID);
} }
} }
@ -276,7 +314,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns> /// <returns></returns>
private bool InventoryContainsName(string name) private bool InventoryContainsName(string name)
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in Items.Values)
{ {
if (item.Name == name) if (item.Name == name)
return true; return true;
@ -322,7 +360,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="item"></param> /// <param name="item"></param>
public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
{ {
List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_taskInventory.Values); List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values);
foreach (TaskInventoryItem i in il) foreach (TaskInventoryItem i in il)
{ {
if (i.Name == item.Name) if (i.Name == item.Name)
@ -355,24 +393,24 @@ namespace OpenSim.Region.Environment.Scenes
if (name == String.Empty) if (name == String.Empty)
return; return;
item.ParentID = UUID; item.ParentID = m_part.UUID;
item.ParentPartID = UUID; item.ParentPartID = m_part.UUID;
item.Name = name; item.Name = name;
lock (m_taskInventory) lock (m_items)
{ {
m_taskInventory.Add(item.ItemID, item); m_items.Add(item.ItemID, item);
if (allowedDrop) if (allowedDrop)
TriggerScriptChangedEvent(Changed.ALLOWED_DROP); m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
else else
TriggerScriptChangedEvent(Changed.INVENTORY); m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
} }
m_inventorySerial++; m_inventorySerial++;
//m_inventorySerial += 2; //m_inventorySerial += 2;
HasInventoryChanged = true; HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true; m_part.ParentGroup.HasGroupChanged = true;
} }
/// <summary> /// <summary>
@ -384,12 +422,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="items"></param> /// <param name="items"></param>
public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) public void RestoreInventoryItems(ICollection<TaskInventoryItem> items)
{ {
lock (m_taskInventory) lock (m_items)
{ {
foreach (TaskInventoryItem item in items) foreach (TaskInventoryItem item in items)
{ {
m_taskInventory.Add(item.ItemID, item); m_items.Add(item.ItemID, item);
TriggerScriptChangedEvent(Changed.INVENTORY); m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
} }
} }
@ -404,7 +442,7 @@ namespace OpenSim.Region.Environment.Scenes
public TaskInventoryItem GetInventoryItem(UUID itemId) public TaskInventoryItem GetInventoryItem(UUID itemId)
{ {
TaskInventoryItem item; TaskInventoryItem item;
m_taskInventory.TryGetValue(itemId, out item); m_items.TryGetValue(itemId, out item);
return item; return item;
} }
@ -417,22 +455,20 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns>false if the item did not exist, true if the update occurred successfully</returns> /// <returns>false if the item did not exist, true if the update occurred successfully</returns>
public bool UpdateInventoryItem(TaskInventoryItem item) public bool UpdateInventoryItem(TaskInventoryItem item)
{ {
lock (m_taskInventory) lock (m_items)
{ {
if (m_taskInventory.ContainsKey(item.ItemID)) if (m_items.ContainsKey(item.ItemID))
{ {
item.ParentID = UUID; item.ParentID = m_part.UUID;
item.ParentPartID = UUID; item.ParentPartID = m_part.UUID;
item.Flags=m_taskInventory[item.ItemID].Flags; item.Flags = m_items[item.ItemID].Flags;
if (item.AssetID == UUID.Zero) if (item.AssetID == UUID.Zero)
{ {
item.AssetID = m_taskInventory[item.ItemID].AssetID; item.AssetID = m_items[item.ItemID].AssetID;
} }
else if ((InventoryType)item.Type == InventoryType.Notecard) else if ((InventoryType)item.Type == InventoryType.Notecard)
{ {
ScenePresence presence = ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID);
m_parentGroup.Scene.GetScenePresence(
item.OwnerID);
if (presence != null) if (presence != null)
{ {
@ -441,12 +477,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
m_taskInventory[item.ItemID] = item; m_items[item.ItemID] = item;
m_inventorySerial++; m_inventorySerial++;
TriggerScriptChangedEvent(Changed.INVENTORY); m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
HasInventoryChanged = true; HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true; m_part.ParentGroup.HasGroupChanged = true;
return true; return true;
} }
@ -455,18 +491,13 @@ namespace OpenSim.Region.Environment.Scenes
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
item.ItemID, Name, UUID); item.ItemID, m_part.Name, m_part.UUID);
} }
} }
return false; return false;
} }
public void AddScriptLPS(int count)
{
m_parentGroup.AddScriptLPS(count);
}
/// <summary> /// <summary>
/// Remove an item from this prim's inventory /// Remove an item from this prim's inventory
/// </summary> /// </summary>
@ -475,37 +506,36 @@ namespace OpenSim.Region.Environment.Scenes
/// in this prim's inventory.</returns> /// in this prim's inventory.</returns>
public int RemoveInventoryItem(UUID itemID) public int RemoveInventoryItem(UUID itemID)
{ {
lock (m_taskInventory) lock (m_items)
{ {
if (m_taskInventory.ContainsKey(itemID)) if (m_items.ContainsKey(itemID))
{ {
int type = m_taskInventory[itemID].InvType; int type = m_items[itemID].InvType;
m_taskInventory.Remove(itemID); m_items.Remove(itemID);
m_inventorySerial++; m_inventorySerial++;
TriggerScriptChangedEvent(Changed.INVENTORY); m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
HasInventoryChanged = true; HasInventoryChanged = true;
ParentGroup.HasGroupChanged = true; m_part.ParentGroup.HasGroupChanged = true;
int scriptcount = 0; int scriptcount = 0;
lock (m_taskInventory) lock (m_items)
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
if (item.Type == 10) if (item.Type == 10)
{ {
scriptcount++; scriptcount++;
} }
} }
} }
if (scriptcount <= 0) if (scriptcount <= 0)
{ {
RemFlag(PrimFlags.Scripted); m_part.RemFlag(PrimFlags.Scripted);
} }
ScheduleFullUpdate(); m_part.ScheduleFullUpdate();
return type; return type;
} }
@ -514,7 +544,7 @@ namespace OpenSim.Region.Environment.Scenes
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
itemID, Name, UUID); itemID, m_part.Name, m_part.UUID);
} }
} }
@ -545,13 +575,13 @@ namespace OpenSim.Region.Environment.Scenes
if (m_inventorySerial > 0) if (m_inventorySerial > 0)
{ {
client.SendTaskInventory(m_uuid, (short)m_inventorySerial, client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
Utils.StringToBytes(GetInventoryFileName())); Utils.StringToBytes(GetInventoryFileName()));
return true; return true;
} }
else else
{ {
client.SendTaskInventory(m_uuid, 0, new byte[0]); client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return false; return false;
} }
} }
@ -567,11 +597,11 @@ namespace OpenSim.Region.Environment.Scenes
// Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches
// what appears to happen in the Second Life protocol. If this isn't the case. then various functionality // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality
// isn't available (such as drag from prim inventory to agent inventory) // isn't available (such as drag from prim inventory to agent inventory)
InventoryStringBuilder invString = new InventoryStringBuilder(UUID, UUID.Zero); InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
lock (m_taskInventory) lock (m_items)
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
UUID ownerID = item.OwnerID; UUID ownerID = item.OwnerID;
uint everyoneMask = 0; uint everyoneMask = 0;
@ -580,7 +610,7 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddItemStart(); invString.AddItemStart();
invString.AddNameValueLine("item_id", item.ItemID.ToString()); invString.AddNameValueLine("item_id", item.ItemID.ToString());
invString.AddNameValueLine("parent_id", UUID.ToString()); invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
invString.AddPermissionsStart(); invString.AddPermissionsStart();
@ -635,9 +665,9 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (HasInventoryChanged) if (HasInventoryChanged)
{ {
lock (TaskInventory) lock (Items)
{ {
datastore.StorePrimInventory(UUID, TaskInventory.Values); datastore.StorePrimInventory(m_part.UUID, Items.Values);
} }
HasInventoryChanged = false; HasInventoryChanged = false;
@ -707,7 +737,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
uint mask=0x7fffffff; uint mask=0x7fffffff;
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
if (item.InvType != 6) if (item.InvType != 6)
{ {
@ -740,11 +770,7 @@ namespace OpenSim.Region.Environment.Scenes
public void ApplyNextOwnerPermissions() public void ApplyNextOwnerPermissions()
{ {
_baseMask &= _nextOwnerMask; foreach (TaskInventoryItem item in m_items.Values)
_ownerMask &= _nextOwnerMask;
_everyoneMask &= _nextOwnerMask;
foreach (TaskInventoryItem item in m_taskInventory.Values)
{ {
if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0) if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0)
{ {
@ -760,12 +786,12 @@ namespace OpenSim.Region.Environment.Scenes
item.EveryonePermissions &= item.NextPermissions; item.EveryonePermissions &= item.NextPermissions;
} }
TriggerScriptChangedEvent(Changed.OWNER); m_part.TriggerScriptChangedEvent(Changed.OWNER);
} }
public void ApplyGodPermissions(uint perms) public void ApplyGodPermissions(uint perms)
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
item.CurrentPermissions = perms; item.CurrentPermissions = perms;
item.BasePermissions = perms; item.BasePermissions = perms;
@ -774,7 +800,7 @@ namespace OpenSim.Region.Environment.Scenes
public bool ContainsScripts() public bool ContainsScripts()
{ {
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
if (item.InvType == 10) if (item.InvType == 10)
{ {
@ -788,7 +814,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
List<UUID> ret = new List<UUID>(); List<UUID> ret = new List<UUID>();
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
ret.Add(item.ItemID); ret.Add(item.ItemID);
return ret; return ret;
@ -796,11 +822,11 @@ namespace OpenSim.Region.Environment.Scenes
public string[] GetScriptAssemblies() public string[] GetScriptAssemblies()
{ {
IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
List<string> ret = new List<string>(); List<string> ret = new List<string>();
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
if (item.InvType == 10) if (item.InvType == 10)
{ {
@ -821,10 +847,10 @@ namespace OpenSim.Region.Environment.Scenes
public Dictionary<UUID, string> GetScriptStates() public Dictionary<UUID, string> GetScriptStates()
{ {
IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_items.Values)
{ {
if (item.InvType == 10) if (item.InvType == 10)
{ {

View File

@ -2558,7 +2558,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (gobj != null) if (gobj != null)
{ {
if (gobj.RootPart.ContainsScripts()) if (gobj.RootPart.Inventory.ContainsScripts())
return true; return true;
} }
} }

View File

@ -268,7 +268,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
localID); localID);
TaskInventoryItem item = TaskInventoryItem item =
part.GetInventoryItem(itemID); part.Inventory.GetInventoryItem(itemID);
ScenePresence presence = ScenePresence presence =
myScriptEngine.World.GetScenePresence( myScriptEngine.World.GetScenePresence(

View File

@ -570,15 +570,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
#endregion #endregion
public void ResetScript(uint localID, UUID itemID) public void ResetScript(uint localID, UUID itemID)
{ {
InstanceData id = GetScript(localID, itemID); InstanceData id = GetScript(localID, itemID);
string script = id.Source; string script = id.Source;
StopScript(localID, itemID); StopScript(localID, itemID);
SceneObjectPart part = World.GetSceneObjectPart(localID); SceneObjectPart part = World.GetSceneObjectPart(localID);
part.GetInventoryItem(itemID).PermsMask = 0; part.Inventory.GetInventoryItem(itemID).PermsMask = 0;
part.GetInventoryItem(itemID).PermsGranter = UUID.Zero; part.Inventory.GetInventoryItem(itemID).PermsGranter = UUID.Zero;
StartScript(localID, itemID, script, id.StartParam, false); StartScript(localID, itemID, script, id.StartParam, false);
} }

View File

@ -3320,7 +3320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (item.Name == name) if (item.Name == name)
{ {
m_host.RemoveInventoryItem(item.ItemID); m_host.Inventory.RemoveInventoryItem(item.ItemID);
return; return;
} }
} }

View File

@ -1032,7 +1032,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
taskItem.PermsMask = 0; taskItem.PermsMask = 0;
taskItem.AssetID = asset.FullID; taskItem.AssetID = asset.FullID;
m_host.AddInventoryItem(taskItem, false); m_host.Inventory.AddInventoryItem(taskItem, false);
} }
} }
} }

View File

@ -302,7 +302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if (part.AttachmentPoint != 0) // Attached so ignore if (part.AttachmentPoint != 0) // Attached so ignore
continue; continue;
if (part.ContainsScripts()) if (part.Inventory.ContainsScripts())
{ {
objtype |= ACTIVE | SCRIPTED; // Scripted and active. It COULD have one hidden ... objtype |= ACTIVE | SCRIPTED; // Scripted and active. It COULD have one hidden ...
} }

View File

@ -141,7 +141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
foreach (SceneObjectPart p in part.ParentGroup.Children.Values) foreach (SceneObjectPart p in part.ParentGroup.Children.Values)
{ {
if (p.ContainsScripts()) if (p.Inventory.ContainsScripts())
{ {
Type |= 0x08; // Scripted Type |= 0x08; // Scripted
break; break;

View File

@ -696,8 +696,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
Stop(0); Stop(0);
SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
part.GetInventoryItem(m_ItemID).PermsMask = 0; part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0;
part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
m_EventQueue.Clear(); m_EventQueue.Clear();
m_Script.ResetVars(); m_Script.ResetVars();
@ -721,8 +721,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_Script.ResetVars(); m_Script.ResetVars();
SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID);
part.GetInventoryItem(m_ItemID).PermsMask = 0; part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0;
part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero;
AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
m_EventQueue.Clear(); m_EventQueue.Clear();

View File

@ -366,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
localID); localID);
TaskInventoryItem item = TaskInventoryItem item =
part.GetInventoryItem(itemID); part.Inventory.GetInventoryItem(itemID);
ScenePresence presence = ScenePresence presence =
m_Scene.GetScenePresence( m_Scene.GetScenePresence(
@ -464,7 +464,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false; return false;
} }
TaskInventoryItem item = part.GetInventoryItem(itemID); TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
if (item == null) if (item == null)
return false; return false;