Fixed handling of inventory a bit

- AssetType isn't InventoryType. Those enums contain different numbers. Use AssetType for the asset type, InventoryType for the inventory type.
- The ToString method (or ToLower) of AssetType/InventoryType doesn't necessarily return the correct LLSD string.
- Replaced several magic numbers by their corresponding enum.
- Fixed the invType for gestures and animations in the library.
This should fix Mantis #3610 and the non-terminating inventory loading
0.6.5-rc1
Homer Horwitz 2009-05-09 21:11:12 +00:00
parent c534d7f614
commit 1d234ca83f
7 changed files with 57 additions and 49 deletions

View File

@ -2045,7 +2045,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// good as having type be specified in the XML.
if (ic.Item.AssetType == (int) AssetType.Unknown ||
ic.Item.InvType == (int) AssetType.Unknown)
ic.Item.InvType == (int) InventoryType.Unknown)
{
Rest.Log.DebugFormat("{0} Attempting to infer item type", MsgId);
@ -2078,8 +2078,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
MsgId, parts[parts.Length-1]);
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageJPEG;
if (ic.Item.InvType == (int) AssetType.Unknown)
ic.Item.InvType = (int) AssetType.ImageJPEG;
if (ic.Item.InvType == (int) InventoryType.Unknown)
ic.Item.InvType = (int) InventoryType.Texture;
break;
case "jpg" :
case "jpeg" :
@ -2087,8 +2087,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
MsgId, parts[parts.Length - 1]);
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageJPEG;
if (ic.Item.InvType == (int) AssetType.Unknown)
ic.Item.InvType = (int) AssetType.ImageJPEG;
if (ic.Item.InvType == (int) InventoryType.Unknown)
ic.Item.InvType = (int) InventoryType.Texture;
break;
case "tga" :
if (parts[parts.Length - 2].IndexOf("_texture") != -1)
@ -2096,14 +2096,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.TextureTGA;
if (ic.Item.InvType == (int) AssetType.Unknown)
ic.Item.InvType = (int) AssetType.TextureTGA;
ic.Item.InvType = (int) InventoryType.Texture;
}
else
{
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageTGA;
if (ic.Item.InvType == (int) AssetType.Unknown)
ic.Item.InvType = (int) AssetType.ImageTGA;
if (ic.Item.InvType == (int) InventoryType.Unknown)
ic.Item.InvType = (int) InventoryType.Snapshot;
}
break;
default :

View File

@ -512,8 +512,16 @@ namespace OpenSim.Framework.Communications.Capabilities
llsdItem.item_id = invItem.ID;
llsdItem.name = invItem.Name;
llsdItem.parent_id = invItem.Folder;
llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower();
llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower();
try
{
// TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions.
llsdItem.type = TaskInventoryItem.Types[invItem.AssetType];
llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType];
}
catch (Exception e)
{
m_log.Error("[CAPS]: Problem setting asset/inventory type while converting inventory item " + invItem.Name + " to LLSD:", e);
}
llsdItem.permissions = new LLSDPermissions();
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;

View File

@ -490,7 +490,7 @@ namespace OpenSim.Region.Framework.Scenes
if (Permissions.PropagatePermissions())
{
if (item.InvType == 6)
if (item.InvType == (int)InventoryType.Object)
{
itemCopy.BasePermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
itemCopy.BasePermissions |= (item.CurrentPermissions & 7) << 13;
@ -899,7 +899,7 @@ namespace OpenSim.Region.Framework.Scenes
TryGetAvatar(remoteClient.AgentId, out presence);
byte[] data = null;
if (invType == 3 && presence != null) // OpenMetaverse.asset.assettype.landmark = 3 - needs to be turned into an enum
if (invType == (sbyte)InventoryType.Landmark && presence != null)
{
Vector3 pos = presence.AbsolutePosition;
string strdata = String.Format(
@ -1098,7 +1098,7 @@ namespace OpenSim.Region.Framework.Scenes
if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
{
if (taskItem.InvType == 6)
if (taskItem.InvType == (int)InventoryType.Object)
agentItem.BasePermissions = taskItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13);
else
agentItem.BasePermissions = taskItem.BasePermissions;

View File

@ -776,7 +776,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType != 6)
if (item.InvType != (int)InventoryType.Object)
{
if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
mask &= ~((uint)PermissionMask.Copy >> 13);
@ -809,7 +809,7 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0)
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
@ -840,7 +840,7 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == 10)
if (item.InvType == (int)InventoryType.LSL)
{
return true;
}
@ -866,7 +866,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == 10)
if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{
@ -890,7 +890,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == 10)
if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{

View File

@ -1351,8 +1351,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
taskItem.Name = asset.Name;
taskItem.Description = asset.Description;
taskItem.Type = 7;
taskItem.InvType = 7;
taskItem.Type = (int)AssetType.Notecard;
taskItem.InvType = (int)InventoryType.Notecard;
taskItem.OwnerID = m_host.OwnerID;
taskItem.CreatorID = m_host.OwnerID;
taskItem.BasePermissions = (uint)PermissionMask.All;

View File

@ -6,7 +6,7 @@
<Key Name="name" Value="place_marker" />
<Key Name="description" Value="simple part-body standing, use low-priority to allow others - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="tpose2">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -15,7 +15,7 @@
<Key Name="name" Value="tpose2" />
<Key Name="description" Value="a tpose more suitable for posing stands - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="bouncy_ball_left">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -24,7 +24,7 @@
<Key Name="name" Value="bouncy_ball_left" />
<Key Name="description" Value="turn left on bouncy ball, grasping - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="tpose">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -33,7 +33,7 @@
<Key Name="name" Value="tpose" />
<Key Name="description" Value="the standard tpose (all must start with this in frame 1) - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="handshake">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -42,7 +42,7 @@
<Key Name="name" Value="handshake" />
<Key Name="description" Value="a simple right-handed, double-pump handshake, (30x30fps) - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="give_and_handshake">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -51,7 +51,7 @@
<Key Name="name" Value="give_and_handshake" />
<Key Name="description" Value="same as handshake, but gives something with left hand first (30x30fps) - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="bouncy_ball_walk">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -60,7 +60,7 @@
<Key Name="name" Value="bouncy_ball_walk" />
<Key Name="description" Value="move foward on bouncy ball, walk speed, grasping - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="bouncy_ball_run">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -69,7 +69,7 @@
<Key Name="name" Value="bouncy_ball_run" />
<Key Name="description" Value="move foward on bouncy ball, run speed, grasping - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="windsurf_left">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -78,7 +78,7 @@
<Key Name="name" Value="windsurf_left" />
<Key Name="description" Value="static, full body, pose of windsurfer, left foot forward - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="bouncy_ball_super">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -87,7 +87,7 @@
<Key Name="name" Value="bouncy_ball_super" />
<Key Name="description" Value="super bounce on bouncy ball, matrix-like, grasping - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="bouncy_ball_right">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -96,7 +96,7 @@
<Key Name="name" Value="bouncy_ball_right" />
<Key Name="description" Value="turn right on bouncy ball, grasping - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>
<Section Name="autograph_right">
<Key Name="folderID" Value="f0908f10-b9bf-11dc-95ff-0800200c9a66"/>
@ -105,7 +105,7 @@
<Key Name="name" Value="autograph_right" />
<Key Name="description" Value="part-body, right-handed signing autograph with left give - contributed by Mo Hax" />
<Key Name="assetType" Value="20" />
<Key Name="inventoryType" Value="20" />
<Key Name="inventoryType" Value="19" />
</Section>

View File

@ -6,7 +6,7 @@
<Key Name="description" Value="2008-10-03 14:10:00 gesture" />
<Key Name="name" Value="can we move along?" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -19,7 +19,7 @@
<Key Name="description" Value="2008-10-03 14:17:16 gesture" />
<Key Name="name" Value="me!" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -32,7 +32,7 @@
<Key Name="description" Value="2008-10-03 14:29:00 gesture" />
<Key Name="name" Value="clap" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -45,7 +45,7 @@
<Key Name="description" Value="2008-10-03 14:10:03 gesture" />
<Key Name="name" Value="no" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -58,7 +58,7 @@
<Key Name="description" Value="2008-10-03 14:17:13 gesture" />
<Key Name="name" Value="suprised" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -71,7 +71,7 @@
<Key Name="description" Value="2008-10-03 14:33:04 gesture" />
<Key Name="name" Value="dance2" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -84,7 +84,7 @@
<Key Name="description" Value="2008-10-03 14:09:55 gesture" />
<Key Name="name" Value="definitely YES" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -97,7 +97,7 @@
<Key Name="description" Value="2008-10-03 14:01:58 gesture" />
<Key Name="name" Value="Wave" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -110,7 +110,7 @@
<Key Name="description" Value="2008-10-03 14:09:45 gesture" />
<Key Name="name" Value="take it outside" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -123,7 +123,7 @@
<Key Name="description" Value="2008-10-03 14:10:06 gesture" />
<Key Name="name" Value="whoohoo!" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -136,7 +136,7 @@
<Key Name="description" Value="2008-10-03 14:03:01 gesture" />
<Key Name="name" Value="raise hand" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -149,7 +149,7 @@
<Key Name="description" Value="2008-10-03 14:09:57 gesture" />
<Key Name="name" Value="LOL" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -162,7 +162,7 @@
<Key Name="description" Value="2008-10-03 14:32:33 gesture" />
<Key Name="name" Value="dance1" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -175,7 +175,7 @@
<Key Name="description" Value="2008-10-03 14:17:09 gesture" />
<Key Name="name" Value="wink!" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -188,7 +188,7 @@
<Key Name="description" Value="2008-10-03 14:10:09 gesture" />
<Key Name="name" Value="not sure" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />
@ -201,7 +201,7 @@
<Key Name="description" Value="2008-10-03 14:33:41 gesture" />
<Key Name="name" Value="dance3" />
<Key Name="assetType" Value="21"/>
<Key Name="inventoryType" Value="21"/>
<Key Name="inventoryType" Value="20"/>
<Key Name="currentPermissions" Value="2147483647"/>
<Key Name="nextPermissions" Value="2147483647"/>
<Key Name="everyonePermissions" Value="2147483647" />