diff --git a/applications/Decoder/Decoder.cs b/applications/Decoder/Decoder.cs index f89c78af..bea9b6bc 100644 --- a/applications/Decoder/Decoder.cs +++ b/applications/Decoder/Decoder.cs @@ -75,7 +75,7 @@ class Decoder { // FIXME Console.WriteLine("sorry, filtering is currently broken :("); return; - grep = String.Join(" ", args); + // grep = String.Join(" ", args); } for (Reset();;) { diff --git a/libsecondlife-cs/AssetSystem/AssetManager.cs b/libsecondlife-cs/AssetSystem/AssetManager.cs index 46dd6e34..f1c8fc99 100644 --- a/libsecondlife-cs/AssetSystem/AssetManager.cs +++ b/libsecondlife-cs/AssetSystem/AssetManager.cs @@ -24,6 +24,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +// #define DEBUG_PACKETS + using System; using System.Collections.Generic; @@ -41,7 +43,6 @@ namespace libsecondlife.AssetSystem /// public class AssetManager { - private const bool DEBUG_PACKETS = false; public const int SINK_FEE_IMAGE = 1; @@ -133,14 +134,18 @@ namespace libsecondlife.AssetSystem { packet = AssetPacketHelpers.AssetUploadRequestHeaderOnly(asset, curUploadRequest.TransactionID); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif curUploadRequest.AssetData = asset.AssetData; } else { packet = AssetPacketHelpers.AssetUploadRequest(asset, curUploadRequest.TransactionID); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } curUploadRequest.Completed.WaitOne(); @@ -184,7 +189,10 @@ namespace libsecondlife.AssetSystem Packet packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item ); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif tr.Completed.WaitOne(); @@ -193,7 +201,10 @@ namespace libsecondlife.AssetSystem private void AssetUploadCompleteCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif + Packets.AssetUploadCompletePacket reply = (AssetUploadCompletePacket)packet; curUploadRequest.AssetID = reply.AssetBlock.UUID; @@ -208,7 +219,10 @@ namespace libsecondlife.AssetSystem private void RequestXferCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif + RequestXferPacket reply = (RequestXferPacket)packet; ulong XferID = reply.XferID.ID; @@ -226,12 +240,18 @@ namespace libsecondlife.AssetSystem packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, 0); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } private void ConfirmXferPacketCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif + ConfirmXferPacketPacket reply = (ConfirmXferPacketPacket)packet; ulong XferID = reply.XferID.ID; @@ -251,7 +271,10 @@ namespace libsecondlife.AssetSystem packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, i); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } else { @@ -263,7 +286,10 @@ namespace libsecondlife.AssetSystem uint lastPacket = (uint)int.MaxValue + (uint)numPackets + (uint)1; packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, lastPacket); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } } else { throw new Exception("Something is wrong with uploading assets, a confirmation came in for a packet we didn't send."); @@ -272,7 +298,10 @@ namespace libsecondlife.AssetSystem private void TransferInfoCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif + TransferInfoPacket reply = (TransferInfoPacket)packet; LLUUID TransferID = reply.TransferInfo.TransferID; @@ -305,7 +334,10 @@ namespace libsecondlife.AssetSystem private void TransferPacketCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif + TransferPacketPacket reply = (TransferPacketPacket)packet; LLUUID TransferID = reply.TransferData.TransferID; diff --git a/libsecondlife-cs/AssetSystem/ImageManager.cs b/libsecondlife-cs/AssetSystem/ImageManager.cs index 6602b6ae..fcc8b6cd 100644 --- a/libsecondlife-cs/AssetSystem/ImageManager.cs +++ b/libsecondlife-cs/AssetSystem/ImageManager.cs @@ -24,6 +24,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +//#define DEBUG_PACKETS + + using System; using System.Collections.Generic; using System.IO; @@ -42,7 +45,6 @@ namespace libsecondlife.AssetSystem /// public class ImageManager { - private const bool DEBUG_PACKETS = true; private SecondLife slClient; @@ -333,7 +335,9 @@ namespace libsecondlife.AssetSystem /// public void ImageDataCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif ImageDataPacket reply = (ImageDataPacket)packet; @@ -382,7 +386,9 @@ namespace libsecondlife.AssetSystem /// public void ImagePacketCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif ImagePacketPacket reply = (ImagePacketPacket)packet; @@ -429,7 +435,9 @@ namespace libsecondlife.AssetSystem /// public void ImageNotInDatabaseCallbackHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif ImageNotInDatabasePacket reply = (ImageNotInDatabasePacket)packet; diff --git a/libsecondlife-cs/InventorySystem/InventoryManager.cs b/libsecondlife-cs/InventorySystem/InventoryManager.cs index 1661e863..1a60230d 100644 --- a/libsecondlife-cs/InventorySystem/InventoryManager.cs +++ b/libsecondlife-cs/InventorySystem/InventoryManager.cs @@ -24,8 +24,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +//#define DEBUG_PACKETS + using System; using System.Collections.Generic; +using System.Threading; using libsecondlife; using libsecondlife.AssetSystem; @@ -40,7 +43,7 @@ namespace libsecondlife.InventorySystem /// public class InventoryManager { - private const bool DEBUG_PACKETS = false; +// private const bool DEBUG_PACKETS = false; // Reference to the SLClient Library @@ -67,7 +70,7 @@ namespace libsecondlife.InventorySystem // Used to track current item being created private InventoryItem iiCreationInProgress; - private bool ItemCreationInProgress; + public ManualResetEvent ItemCreationCompleted; private uint LastPacketRecieved; @@ -246,37 +249,45 @@ namespace libsecondlife.InventorySystem internal void ItemCreate(InventoryItem iitem) { - if (ItemCreationInProgress) + if( iiCreationInProgress != null ) { throw new Exception("Can only create one item at a time, and an item creation is already in progress."); } - else - { - ItemCreationInProgress = true; // This is released when we receive UpdateCreateInventoryItemHandler - iiCreationInProgress = iitem; - } + + ItemCreationCompleted = new ManualResetEvent(false); + iiCreationInProgress = iitem; + Packet packet = InvPacketHelper.CreateInventoryItem(iitem); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - while (ItemCreationInProgress) - { - slClient.Tick(); - } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif + + ItemCreationCompleted.WaitOne(); + + iiCreationInProgress = null; } internal void ItemUpdate(InventoryItem iitem) { Packet packet = InvPacketHelper.UpdateInventoryItem(iitem); slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } internal void ItemCopy(LLUUID ItemID, LLUUID TargetFolderID) { Packet packet = InvPacketHelper.CopyInventoryItem(ItemID, TargetFolderID); slClient.Network.SendPacket(packet); + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } internal void ItemGiveTo(InventoryItem iitem, LLUUID ToAgentID) @@ -293,6 +304,9 @@ namespace libsecondlife.InventorySystem slClient.Network.SendPacket(packet); + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } internal void ItemRemove(InventoryItem iitem) @@ -302,6 +316,10 @@ namespace libsecondlife.InventorySystem Packet packet = InvPacketHelper.RemoveInventoryItem(iitem.ItemID); slClient.Network.SendPacket(packet); + + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif } internal InventoryNotecard NewNotecard(string Name, string Description, string Body, LLUUID FolderID) @@ -409,9 +427,11 @@ namespace libsecondlife.InventorySystem public void UpdateCreateInventoryItemHandler(Packet packet, Simulator simulator) { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } + #if DEBUG_PACKETS + Console.WriteLine(packet); + #endif - if (ItemCreationInProgress) + if (iiCreationInProgress == null) { UpdateCreateInventoryItemPacket reply = (UpdateCreateInventoryItemPacket)packet; @@ -442,7 +462,7 @@ namespace libsecondlife.InventorySystem // NOT USED YET: iiCreationInProgress._CallbackID = reply.InventoryData[0].CallbackID; - ItemCreationInProgress = false; + ItemCreationCompleted.Set(); } else {