From 554c8b551402bc2d6efaa6c135f954290b3d8fea Mon Sep 17 00:00:00 2001 From: deviltti Date: Fri, 10 Jun 2016 21:14:28 -0400 Subject: [PATCH] Fixed packet Console output --- FFXIVClassic Lobby Server/packets/BasePacket.cs | 8 ++++++-- FFXIVClassic Lobby Server/packets/SubPacket.cs | 16 ++++++++++------ FFXIVClassic Map Server/packets/BasePacket.cs | 10 +++++++--- FFXIVClassic Map Server/packets/SubPacket.cs | 16 ++++++++++------ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/FFXIVClassic Lobby Server/packets/BasePacket.cs b/FFXIVClassic Lobby Server/packets/BasePacket.cs index d4ee5a2f..3f9b356b 100644 --- a/FFXIVClassic Lobby Server/packets/BasePacket.cs +++ b/FFXIVClassic Lobby Server/packets/BasePacket.cs @@ -335,10 +335,14 @@ namespace FFXIVClassic_Lobby_Server.packets { #if DEBUG Console.BackgroundColor = ConsoleColor.DarkYellow; - Log.Debug(String.Format("IsAuthed: {0}, IsEncrypted: {1}, Size: 0x{2:X}, Num Subpackets: {3}", header.isAuthenticated, header.isEncrypted, header.packetSize, header.numSubpackets)); - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes()))); + + Log.Debug(String.Format("IsAuth: {0} IsEncrypted: {1}, Size: 0x{2:X}, NumSubpackets: {3}{4}{5}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + foreach (SubPacket sub in getSubpackets()) + { sub.debugPrintSubPacket(); + } + Console.BackgroundColor = ConsoleColor.Black; #endif } diff --git a/FFXIVClassic Lobby Server/packets/SubPacket.cs b/FFXIVClassic Lobby Server/packets/SubPacket.cs index 3d988135..18bdb652 100644 --- a/FFXIVClassic Lobby Server/packets/SubPacket.cs +++ b/FFXIVClassic Lobby Server/packets/SubPacket.cs @@ -141,14 +141,18 @@ namespace FFXIVClassic_Lobby_Server.packets { #if DEBUG Console.BackgroundColor = ConsoleColor.DarkRed; - Log.Debug(String.Format("Size: 0x{0:X}", header.subpacketSize)); + + Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + if (header.type == 0x03) - Log.Debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode)); - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes()))); - if (header.type == 0x03) - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getGameMessageBytes()))); + { + Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE))); + } + Console.BackgroundColor = ConsoleColor.DarkMagenta; - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(data))); + + Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE))); + Console.BackgroundColor = ConsoleColor.Black; #endif } diff --git a/FFXIVClassic Map Server/packets/BasePacket.cs b/FFXIVClassic Map Server/packets/BasePacket.cs index 0f6e0914..9897d2a7 100644 --- a/FFXIVClassic Map Server/packets/BasePacket.cs +++ b/FFXIVClassic Map Server/packets/BasePacket.cs @@ -333,13 +333,17 @@ namespace FFXIVClassic_Map_Server.packets { #if DEBUG Console.BackgroundColor = ConsoleColor.DarkYellow; - Log.Debug(String.Format("IsAuthed: {0}, IsEncrypted: {1}, Size: 0x{2:X}, Num Subpackets: {3}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets)); - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes()))); + + Log.Debug(String.Format("IsAuth: {0} IsEncrypted: {1}, Size: 0x{2:X}, NumSubpackets: {3}{4}{5}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + foreach (SubPacket sub in getSubpackets()) + { sub.debugPrintSubPacket(); + } + Console.BackgroundColor = ConsoleColor.Black; #endif } - + } } diff --git a/FFXIVClassic Map Server/packets/SubPacket.cs b/FFXIVClassic Map Server/packets/SubPacket.cs index 54da7092..ebf8c78c 100644 --- a/FFXIVClassic Map Server/packets/SubPacket.cs +++ b/FFXIVClassic Map Server/packets/SubPacket.cs @@ -141,14 +141,18 @@ namespace FFXIVClassic_Map_Server.packets { #if DEBUG Console.BackgroundColor = ConsoleColor.DarkRed; - Log.Debug(String.Format("Size: 0x{0:X}", header.subpacketSize)); + + Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + if (header.type == 0x03) - Log.Debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode)); - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes()))); - if (header.type == 0x03) - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getGameMessageBytes()))); + { + Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE))); + } + Console.BackgroundColor = ConsoleColor.DarkMagenta; - Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(data))); + + Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE))); + Console.BackgroundColor = ConsoleColor.Black; #endif }