* Committing patch from mantis 0001297: [PATCH] Fix behavior of child prim inventories. Also enables 'New Script' button. from Melanie. Thanks Melanie!

0.6.0-stable
Teravus Ovares 2008-05-16 23:11:00 +00:00
parent ebb0cc5dd7
commit aa5197304e
6 changed files with 89 additions and 25 deletions

View File

@ -564,7 +564,7 @@ namespace OpenSim.Framework
public delegate void RequestAsset(IClientAPI remoteClient, RequestAssetArgs transferRequest);
public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void RezScript(IClientAPI remoteClient, InventoryItemBase item, LLUUID transactionID, uint localID);
public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID);

View File

@ -5007,10 +5007,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
handlerRezScript = OnRezScript;
InventoryItemBase item=new InventoryItemBase();
item.ID=rezScriptx.InventoryBlock.ItemID;
item.Folder=rezScriptx.InventoryBlock.FolderID;
item.Creator=rezScriptx.InventoryBlock.CreatorID;
item.Owner=rezScriptx.InventoryBlock.OwnerID;
item.BasePermissions=rezScriptx.InventoryBlock.BaseMask;
item.CurrentPermissions=rezScriptx.InventoryBlock.OwnerMask;
item.EveryOnePermissions=rezScriptx.InventoryBlock.EveryoneMask;
item.NextPermissions=rezScriptx.InventoryBlock.NextOwnerMask;
item.GroupOwned=rezScriptx.InventoryBlock.GroupOwned;
item.GroupID=rezScriptx.InventoryBlock.GroupID;
item.AssetType=rezScriptx.InventoryBlock.Type;
item.InvType=rezScriptx.InventoryBlock.InvType;
item.Flags=rezScriptx.InventoryBlock.Flags;
item.SaleType=rezScriptx.InventoryBlock.SaleType;
item.SalePrice=rezScriptx.InventoryBlock.SalePrice;
item.Name=Util.FieldToString(rezScriptx.InventoryBlock.Name);
item.Description=Util.FieldToString(rezScriptx.InventoryBlock.Description);
item.CreationDate=(int)rezScriptx.InventoryBlock.CreationDate;
if (handlerRezScript != null)
{
handlerRezScript(this, rezScriptx.InventoryBlock.ItemID, rezScriptx.UpdateBlock.ObjectLocalID);
handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
}
break;

View File

@ -221,7 +221,7 @@ namespace OpenSim.Region.Environment.Scenes
// Update item with new asset
item.AssetID = asset.FullID;
group.UpdateInventoryItem(item);
group.GetProperties(remoteClient);
part.GetProperties(remoteClient);
// Trigger rerunning of script (use TriggerRezScript event, see RezScript)
if (isScriptRunning)
@ -572,7 +572,7 @@ namespace OpenSim.Region.Environment.Scenes
private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
AssetBase asset, uint nextOwnerMask)
{
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask, nextOwnerMask, 0, nextOwnerMask);
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask);
}
/// <summary>
@ -789,11 +789,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param>
public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
{
SceneObjectGroup group = GetGroupByPrim(localID);
SceneObjectPart part = GetSceneObjectPart(localID);
SceneObjectGroup group = part.ParentGroup;
if (group != null)
{
int type = group.RemoveInventoryItem(localID, itemID);
group.GetProperties(remoteClient);
part.GetProperties(remoteClient);
if (type == 10)
{
EventManager.TriggerRemoveScript(localID, itemID);
@ -917,7 +918,7 @@ namespace OpenSim.Region.Environment.Scenes
m_log.InfoFormat(
"[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
item.Name, primLocalID, remoteClient.Name);
part.ParentGroup.GetProperties(remoteClient);
part.GetProperties(remoteClient);
if (!ExternalChecks.ExternalChecksBypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
@ -948,8 +949,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param>
/// <param name="itemID"> </param>
/// <param name="localID"></param>
public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, LLUUID transactionID, uint localID)
{
LLUUID itemID=itemBase.ID;
LLUUID copyID = LLUUID.Random();
if (itemID != LLUUID.Zero)
@ -974,7 +976,7 @@ namespace OpenSim.Region.Environment.Scenes
{
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
part.ParentGroup.StartScript(localID, copyID);
part.ParentGroup.GetProperties(remoteClient);
part.GetProperties(remoteClient);
// m_log.InfoFormat("[PRIMINVENTORY]: " +
// "Rezzed script {0} into prim local ID {1} for user {2}",
@ -999,11 +1001,38 @@ namespace OpenSim.Region.Environment.Scenes
}
else // If the itemID is zero then the script has been rezzed directly in an object's inventory
{
// not yet implemented
// TODO Need to get more details from original RezScript packet
// XXX jc tmp
// AssetBase asset = CreateAsset("chimney sweep", "sailor.lsl", 10, 10, null);
// AssetCache.AddAsset(asset);
SceneObjectPart part=GetSceneObjectPart(itemBase.Folder);
if(part == null)
return;
AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.InvType, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"));
AssetCache.AddAsset(asset);
TaskInventoryItem taskItem=new TaskInventoryItem();
taskItem.ResetIDs(itemBase.Folder);
taskItem.ParentID = itemBase.Folder;
taskItem.CreationDate = (uint)itemBase.CreationDate;
taskItem.Name = itemBase.Name;
taskItem.Description = itemBase.Description;
taskItem.Type = itemBase.AssetType;
taskItem.InvType = itemBase.InvType;
taskItem.OwnerID = itemBase.Owner;
taskItem.CreatorID = itemBase.Creator;
taskItem.BaseMask = itemBase.BasePermissions;
taskItem.OwnerMask = itemBase.CurrentPermissions;
taskItem.EveryoneMask = itemBase.EveryOnePermissions;
taskItem.NextOwnerMask = itemBase.NextPermissions;
taskItem.GroupID = itemBase.GroupID;
taskItem.GroupMask = 0;
taskItem.Flags = itemBase.Flags;
taskItem.PermsGranter = LLUUID.Zero;
taskItem.PermsMask = 0;
taskItem.AssetID = asset.ID;
part.AddInventoryItem(taskItem);
part.GetProperties(remoteClient);
part.StartScript(taskItem);
}
}

View File

@ -1927,13 +1927,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="client"></param>
public void GetProperties(IClientAPI client)
{
client.SendObjectPropertiesReply(LLUUID.Zero, (ulong)m_rootPart.CreationDate, m_rootPart.CreatorID, LLUUID.Zero, LLUUID.Zero,
LLUUID.Zero, (short)m_rootPart.InventorySerial, m_rootPart.LastOwnerID, UUID, m_rootPart.OwnerID,
m_rootPart.TouchName, new byte[0], m_rootPart.SitName, m_rootPart.Name, m_rootPart.Description,
m_rootPart.OwnerMask, m_rootPart.NextOwnerMask, m_rootPart.GroupMask, m_rootPart.EveryoneMask,
m_rootPart.BaseMask);
m_rootPart.GetProperties(client);
}
/// <summary>

View File

@ -42,6 +42,7 @@ namespace OpenSim.Region.Environment.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_inventoryFileName = String.Empty;
private int m_inventoryFileNameSerial = 0;
/// <summary>
/// Exposing this is not particularly good, but it's one of the least evils at the moment to see
@ -444,6 +445,17 @@ namespace OpenSim.Region.Environment.Scenes
return -1;
}
public string GetInventoryFileName()
{
if(m_inventoryFileName == String.Empty)
m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
if(m_inventoryFileNameSerial < m_inventorySerial)
{
m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
}
return m_inventoryFileName;
}
/// <summary>
/// Return the name with which a client can request a xfer of this prim's inventory metadata
/// </summary>
@ -458,7 +470,7 @@ namespace OpenSim.Region.Environment.Scenes
if (m_inventorySerial > 0)
{
client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
Helpers.StringToField(m_inventoryFileName));
Helpers.StringToField(GetInventoryFileName()));
return true;
}
else

View File

@ -759,7 +759,6 @@ namespace OpenSim.Region.Environment.Scenes
public SceneObjectPart()
{
// It's not necessary to persist this
m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
m_TextureAnimation = new byte[0];
}
@ -808,7 +807,6 @@ namespace OpenSim.Region.Environment.Scenes
AngularVelocity = new LLVector3(0, 0, 0);
Acceleration = new LLVector3(0, 0, 0);
m_TextureAnimation = new byte[0];
m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
// Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
// this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@ -2530,7 +2528,7 @@ namespace OpenSim.Region.Environment.Scenes
throw new ArgumentNullException("info");
}
info.AddValue("m_inventoryFileName", m_inventoryFileName);
info.AddValue("m_inventoryFileName", GetInventoryFileName());
info.AddValue("m_folderID", UUID);
info.AddValue("PhysActor", PhysActor);
@ -2758,5 +2756,17 @@ namespace OpenSim.Region.Environment.Scenes
return m_parentGroup.RootPart.DIE_AT_EDGE;
}
public void GetProperties(IClientAPI client)
{
client.SendObjectPropertiesReply(LLUUID.Zero, (ulong)CreationDate, CreatorID, LLUUID.Zero, LLUUID.Zero,
LLUUID.Zero, (short)InventorySerial, LastOwnerID, UUID, OwnerID,
ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description,
ParentGroup.RootPart.OwnerMask, ParentGroup.RootPart.NextOwnerMask, ParentGroup.RootPart.GroupMask, ParentGroup.RootPart.EveryoneMask,
ParentGroup.RootPart.BaseMask);
}
}
}