From 026cd5bfd3e351e61a655b3065779cd2f6ba97da Mon Sep 17 00:00:00 2001 From: Michael Cortez Date: Mon, 14 Aug 2006 20:32:31 +0000 Subject: [PATCH] Centralizing the Asset/Inventory Systems' packets to the main libsecondlife.Packet name space. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@162 52acb1d6-8a22-11de-b505-999d5b087335 --- .../InventorySystem/InventoryImage.cs | 2 +- .../InventorySystem/InventoryItem.cs | 4 +- .../InventorySystem/InventoryManager.cs | 2 +- .../InventorySystem/InventoryNotecard.cs | 2 +- libsecondlife-cs/Packets/InventoryPackets.cs | 304 ++++++++++++++++-- libsecondlife-cs/libsecondlife.csproj | 35 +- libsecondlife-cs/libsecondlife.sln | 8 - 7 files changed, 295 insertions(+), 62 deletions(-) diff --git a/libsecondlife-cs/InventorySystem/InventoryImage.cs b/libsecondlife-cs/InventorySystem/InventoryImage.cs index aea168f1..0b7783ad 100644 --- a/libsecondlife-cs/InventorySystem/InventoryImage.cs +++ b/libsecondlife-cs/InventorySystem/InventoryImage.cs @@ -109,7 +109,7 @@ namespace libsecondlife.InventorySystem output += "description = '" + xmlSafe(Description) + "' "; output += "crc = '" + CRC + "' "; - output += "debug = '" + PacketHelpers.UpdateInventoryItem.BuildCRC(this) + "' "; + output += "debug = '" + Packets.InventoryPackets.InventoryUpdateCRC(this) + "' "; output += "ownerid = '" + OwnerID + "' "; output += "creatorid = '" + CreatorID + "' "; diff --git a/libsecondlife-cs/InventorySystem/InventoryItem.cs b/libsecondlife-cs/InventorySystem/InventoryItem.cs index 3f56764e..b5ca9c83 100644 --- a/libsecondlife-cs/InventorySystem/InventoryItem.cs +++ b/libsecondlife-cs/InventorySystem/InventoryItem.cs @@ -306,7 +306,7 @@ namespace libsecondlife.InventorySystem private void UpdateCRC() { - _CRC = PacketHelpers.UpdateInventoryItem.BuildCRC(this); + _CRC = Packets.InventoryPackets.InventoryUpdateCRC(this); } public void MoveTo( InventoryFolder targetFolder ) @@ -369,7 +369,7 @@ namespace libsecondlife.InventorySystem output += "description = '" + xmlSafe(Description) + "' "; output += "crc = '" + CRC + "' "; - output += "debug = '" + PacketHelpers.UpdateInventoryItem.BuildCRC(this) + "' "; + output += "debug = '" + Packets.InventoryPackets.InventoryUpdateCRC(this) + "' "; output += "ownerid = '" + OwnerID + "' "; output += "creatorid = '" + CreatorID + "' "; diff --git a/libsecondlife-cs/InventorySystem/InventoryManager.cs b/libsecondlife-cs/InventorySystem/InventoryManager.cs index 3fbbdaf0..e3607be1 100644 --- a/libsecondlife-cs/InventorySystem/InventoryManager.cs +++ b/libsecondlife-cs/InventorySystem/InventoryManager.cs @@ -248,7 +248,7 @@ namespace libsecondlife.InventorySystem internal void ItemUpdate( InventoryItem iitem ) { - Packet packet = InventorySystem.PacketHelpers.UpdateInventoryItem.BuildPacket( slClient.Protocol, iitem, slClient.Network.AgentID ); + Packet packet = InventoryPackets.UpdateInventoryItem( slClient.Protocol, iitem, slClient.Network.AgentID ); slClient.Network.SendPacket(packet); } diff --git a/libsecondlife-cs/InventorySystem/InventoryNotecard.cs b/libsecondlife-cs/InventorySystem/InventoryNotecard.cs index 345b3d0a..c9c6fc52 100644 --- a/libsecondlife-cs/InventorySystem/InventoryNotecard.cs +++ b/libsecondlife-cs/InventorySystem/InventoryNotecard.cs @@ -106,7 +106,7 @@ namespace libsecondlife.InventorySystem output += "description = '" + xmlSafe(Description) + "' "; output += "crc = '" + CRC + "' "; - output += "debug = '" + PacketHelpers.UpdateInventoryItem.BuildCRC(this) + "' "; + output += "debug = '" + Packets.InventoryPackets.InventoryUpdateCRC(this) + "' "; output += "ownerid = '" + OwnerID + "' "; output += "creatorid = '" + CreatorID + "' "; diff --git a/libsecondlife-cs/Packets/InventoryPackets.cs b/libsecondlife-cs/Packets/InventoryPackets.cs index 97bc7253..8fbe89c2 100644 --- a/libsecondlife-cs/Packets/InventoryPackets.cs +++ b/libsecondlife-cs/Packets/InventoryPackets.cs @@ -270,15 +270,15 @@ namespace libsecondlife.Packets return PacketBuilder.BuildPacket("UpdateInventoryFolder", protocol, blocks, Helpers.MSG_RELIABLE | Helpers.MSG_ZEROCODED); } -/* -Low 00323 - MoveInventoryItem - Untrusted - Unencoded - 0065 InventoryData (Variable) - 0968 ItemID (LLUUID / 1) - 1025 FolderID (LLUUID / 1) - 1297 AgentData (01) - 0219 AgentID (LLUUID / 1) - 1252 Stamp (BOOL / 1) -*/ + /* + Low 00323 - MoveInventoryItem - Untrusted - Unencoded + 0065 InventoryData (Variable) + 0968 ItemID (LLUUID / 1) + 1025 FolderID (LLUUID / 1) + 1297 AgentData (01) + 0219 AgentID (LLUUID / 1) + 1252 Stamp (BOOL / 1) + */ public static Packet MoveInventoryItem(ProtocolManager protocol , LLUUID agentID , LLUUID itemID @@ -426,23 +426,279 @@ Low 00323 - MoveInventoryItem - Untrusted - Unencoded + /* + Low 00337 - RequestInventoryAsset - Trusted - Zerocoded + 1266 QueryData (01) + 0219 AgentID (LLUUID / 1) + 0640 QueryID (LLUUID / 1) + 0719 OwnerID (LLUUID / 1) + 0968 ItemID (LLUUID / 1) + Low 00338 - InventoryAssetResponse - Trusted - Zerocoded + 1266 QueryData (01) + 0640 QueryID (LLUUID / 1) + 0680 AssetID (LLUUID / 1) + 1058 IsReadable (BOOL / 1) + */ + public static Packet RequestInventoryAsset(ProtocolManager protocol + , LLUUID agentID, LLUUID queryUD, LLUUID ownerID, LLUUID itemID ) + { + int packetLength = 8; // header + packetLength += 16; // AgentID (UUID) + packetLength += 16; // QueryID (UUID) + packetLength += 16; // OwnerID (UUID) + packetLength += 16; // ItemID (UUID) + + Packet packet = new Packet("RequestInventoryAsset", protocol, packetLength ); + + int pos = 8; // Leave room for header + + // AgentID + Array.Copy(agentID.Data, 0, packet.Data, pos, 16); + pos += 16; + + // QueryID + Array.Copy(queryUD.Data, 0, packet.Data, pos, 16); + pos += 16; + + // OwnerID + Array.Copy(ownerID.Data, 0, packet.Data, pos, 16); + pos += 16; + + // ItemID + Array.Copy(itemID.Data, 0, packet.Data, pos, 16); + pos += 16; + + // Set the packet flags + packet.Data[0] = Helpers.MSG_ZEROCODED + Helpers.MSG_RELIABLE; + + return packet; + } + + /* + Low 00322 - UpdateInventoryItemAsset - Untrusted - Unencoded + 0065 InventoryData (Variable) + 0680 AssetID (LLUUID / 1) + 0968 ItemID (LLUUID / 1) + 1297 AgentData (01) + 0219 AgentID (LLUUID / 1) + Low 00326 - ChangeInventoryItemFlags - Untrusted - Zerocoded + 0065 InventoryData (Variable) + 0968 ItemID (LLUUID / 1) + 1189 Flags (U32 / 1) + 1297 AgentData (01) + 0219 AgentID (LLUUID / 1) + */ + + public static Packet UpdateInventoryItem(ProtocolManager protocol, InventoryItem iitem, LLUUID agentID) + { + return UpdateInventoryItem( protocol + , iitem.GroupOwned + , InventoryUpdateCRC(iitem) + , iitem.CreationDate + , iitem.SaleType + , iitem.BaseMask + , iitem.Name + , iitem.InvType + , iitem.Type + , iitem.AssetID + , iitem.GroupID + , iitem.SalePrice + , iitem.OwnerID + , iitem.CreatorID + , iitem.ItemID + , iitem.FolderID + , iitem.EveryoneMask + , iitem.Description + , iitem.Flags + , iitem.NextOwnerMask + , iitem.GroupMask + , iitem.OwnerMask + , agentID + + ); + } + + /* + Low 00321 - UpdateInventoryItem - Untrusted - Unencoded + 0065 InventoryData (Variable) + 0047 GroupOwned (BOOL / 1) + 0149 CRC (U32 / 1) + 0159 CreationDate (S32 / 1) + 0345 SaleType (U8 / 1) + 0395 BaseMask (U32 / 1) + 0506 Name (Variable / 1) + 0562 InvType (S8 / 1) + 0630 Type (S8 / 1) + 0680 AssetID (LLUUID / 1) + 0699 GroupID (LLUUID / 1) + 0716 SalePrice (S32 / 1) + 0719 OwnerID (LLUUID / 1) + 0736 CreatorID (LLUUID / 1) + 0968 ItemID (LLUUID / 1) + 1025 FolderID (LLUUID / 1) + 1084 EveryoneMask (U32 / 1) + 1101 Description (Variable / 1) + 1189 Flags (U32 / 1) + 1348 NextOwnerMask (U32 / 1) + 1452 GroupMask (U32 / 1) + 1505 OwnerMask (U32 / 1) + 1297 AgentData (01) + 0219 AgentID (LLUUID / 1) + + + ----- UpdateInventoryItem ----- + InventoryData + GroupOwned: False + CRC: 3330379543 + CreationDate: 1152566548 + SaleType: 0 + BaseMask: 2147483647 + Name: New Note + InvType: 7 + Type: 7 + AssetID: 00000000000000000000000000000000 + GroupID: 00000000000000000000000000000000 + SalePrice: 10 + OwnerID: 25472683cb324516904a6cd0ecabf128 + CreatorID: 25472683cb324516904a6cd0ecabf128 + ItemID: 6f11a788c6478fb50610b65b4a8f9c11 + FolderID: a4947fc066c247518d9854aaf90097f4 + EveryoneMask: 0 + Description: 2006-07-10 14:22:38 note card + Flags: 0 + NextOwnerMask: 2147483647 + GroupMask: 0 + OwnerMask: 2147483647 + AgentData + AgentID: 25472683cb324516904a6cd0ecabf128 + + */ + private static Packet UpdateInventoryItem(ProtocolManager protocol + , bool groupOwned + , uint crc + , int creationDate + , byte saleType + , uint baseMask + , string name + , sbyte invType, sbyte type + , LLUUID assetID + , LLUUID groupID + , int salePrice + , LLUUID ownerID + , LLUUID creatorID + , LLUUID itemID + , LLUUID folderID + , uint everyoneMask + , string description + , uint flags + , uint nextOwnerMask + , uint groupMask + , uint ownerMask + , LLUUID agentID + ) + { + Hashtable blocks = new Hashtable(); + Hashtable fields = new Hashtable(); + + fields["GroupOwned"] = groupOwned; + fields["CRC"] = crc; + fields["CreationDate"] = creationDate; + fields["SaleType"] = saleType; + fields["BaseMask"] = baseMask; + fields["Name"] = name; + fields["InvType"] = invType; + fields["Type"] = type; + fields["AssetID"] = assetID; + fields["GroupID"] = groupID; + fields["SalePrice"] = salePrice; + fields["OwnerID"] = ownerID; + fields["CreatorID"] = creatorID; + fields["ItemID"] = itemID; + fields["FolderID"] = folderID; + fields["EveryoneMask"] = everyoneMask; + fields["Description"] = description; + fields["Flags"] = flags; + fields["NextOwnerMask"] = nextOwnerMask; + fields["GroupMask"] = groupMask; + fields["OwnerMask"] = ownerMask; + blocks[fields] = "InventoryData"; + + fields = new Hashtable(); + fields["AgentID"] = agentID; + blocks[fields] = "AgentData"; + + return PacketBuilder.BuildPacket("UpdateInventoryItem", protocol, blocks, Helpers.MSG_RELIABLE); + } + public static uint InventoryUpdateCRC(InventoryItem iitem) + { + return InventoryUpdateCRC( + iitem.CreationDate + , iitem.SaleType + , iitem.InvType + , iitem.Type + , iitem.AssetID + , iitem.GroupID + , iitem.SalePrice + , iitem.OwnerID + , iitem.CreatorID + , iitem.ItemID + , iitem.FolderID + , iitem.EveryoneMask + , iitem.Flags + , iitem.NextOwnerMask + , iitem.GroupMask + , iitem.OwnerMask + ); + } -/* -Low 00322 - UpdateInventoryItemAsset - Untrusted - Unencoded - 0065 InventoryData (Variable) - 0680 AssetID (LLUUID / 1) - 0968 ItemID (LLUUID / 1) - 1297 AgentData (01) - 0219 AgentID (LLUUID / 1) -Low 00326 - ChangeInventoryItemFlags - Untrusted - Zerocoded - 0065 InventoryData (Variable) - 0968 ItemID (LLUUID / 1) - 1189 Flags (U32 / 1) - 1297 AgentData (01) - 0219 AgentID (LLUUID / 1) -*/ + private static uint InventoryUpdateCRC ( + int creationDate + , byte saleType + , sbyte invType, sbyte type + , LLUUID assetID + , LLUUID groupID + , int salePrice + , LLUUID ownerID + , LLUUID creatorID + , LLUUID itemID + , LLUUID folderID + , uint everyoneMask + , uint flags + , uint nextOwnerMask + , uint groupMask + , uint ownerMask + ) + { + + uint CRC = 0; + + /* IDs */ + CRC += assetID.CRC(); // AssetID + CRC += folderID.CRC(); // FolderID + CRC += itemID.CRC(); // ItemID + + /* Permission stuff */ + CRC += creatorID.CRC(); // CreatorID + CRC += ownerID.CRC(); // OwnerID + CRC += groupID.CRC(); // GroupID + + /* CRC += another 4 words which always seem to be zero -- unclear if this is a LLUUID or what */ + CRC += ownerMask; //owner_mask; // Either owner_mask or next_owner_mask may need to be + CRC += nextOwnerMask; //next_owner_mask; // switched with base_mask -- 2 values go here and in my + CRC += everyoneMask; //everyone_mask; // study item, the three were identical. + CRC += groupMask; //group_mask; + + /* The rest of the CRC fields */ + CRC += flags; // Flags + CRC += (uint)invType; // InvType + CRC += (uint)type; // Type + CRC += (uint)creationDate; // CreationDate + CRC += (uint)salePrice; // SalePrice + CRC += (uint)((uint)saleType * 0x07073096); // SaleType + + return CRC; + } } - } diff --git a/libsecondlife-cs/libsecondlife.csproj b/libsecondlife-cs/libsecondlife.csproj index 22f0532b..37934183 100644 --- a/libsecondlife-cs/libsecondlife.csproj +++ b/libsecondlife-cs/libsecondlife.csproj @@ -173,16 +173,6 @@ SubType = "Code" BuildAction = "Compile" /> - - - - - + +