From 16d477997053d6f349efb9eec18f1d970b87411b Mon Sep 17 00:00:00 2001 From: deviltti Date: Fri, 10 Jun 2016 22:40:46 -0400 Subject: [PATCH] Fixed packet ByteArrayToHex output --- FFXIVClassic Lobby Server/common/Utils.cs | 22 ++++++++++--------- .../packets/BasePacket.cs | 2 +- FFXIVClassic Map Server/common/Utils.cs | 22 ++++++++++--------- FFXIVClassic Map Server/packets/SubPacket.cs | 8 +++---- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/FFXIVClassic Lobby Server/common/Utils.cs b/FFXIVClassic Lobby Server/common/Utils.cs index 6c5a6aef..8329864c 100644 --- a/FFXIVClassic Lobby Server/common/Utils.cs +++ b/FFXIVClassic Lobby Server/common/Utils.cs @@ -38,16 +38,18 @@ namespace FFXIVClassic_Lobby_Server.common StringBuilder sb = new StringBuilder(numLines * lineLength); - for (int i = offset; i < bytes.Length; i += bytesPerLine) - { - line[0] = hexChars[(i >> 28) & 0xF]; - line[1] = hexChars[(i >> 24) & 0xF]; - line[2] = hexChars[(i >> 20) & 0xF]; - line[3] = hexChars[(i >> 16) & 0xF]; - line[4] = hexChars[(i >> 12) & 0xF]; - line[5] = hexChars[(i >> 8) & 0xF]; - line[6] = hexChars[(i >> 4) & 0xF]; - line[7] = hexChars[(i >> 0) & 0xF]; + for (int i = 0; i < bytes.Length; i += bytesPerLine) + { + int h = i + offset; + + line[0] = hexChars[(h >> 28) & 0xF]; + line[1] = hexChars[(h >> 24) & 0xF]; + line[2] = hexChars[(h >> 20) & 0xF]; + line[3] = hexChars[(h >> 16) & 0xF]; + line[4] = hexChars[(h >> 12) & 0xF]; + line[5] = hexChars[(h >> 8) & 0xF]; + line[6] = hexChars[(h >> 4) & 0xF]; + line[7] = hexChars[(h >> 0) & 0xF]; int hexColumn = offsetBlock; int charColumn = byteBlock; diff --git a/FFXIVClassic Lobby Server/packets/BasePacket.cs b/FFXIVClassic Lobby Server/packets/BasePacket.cs index 3f9b356b..d0d3df2e 100644 --- a/FFXIVClassic Lobby Server/packets/BasePacket.cs +++ b/FFXIVClassic Lobby Server/packets/BasePacket.cs @@ -336,7 +336,7 @@ namespace FFXIVClassic_Lobby_Server.packets #if DEBUG Console.BackgroundColor = ConsoleColor.DarkYellow; - 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()))); + Log.Debug(String.Format("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); foreach (SubPacket sub in getSubpackets()) { diff --git a/FFXIVClassic Map Server/common/Utils.cs b/FFXIVClassic Map Server/common/Utils.cs index 60127881..8fc58dbb 100644 --- a/FFXIVClassic Map Server/common/Utils.cs +++ b/FFXIVClassic Map Server/common/Utils.cs @@ -39,16 +39,18 @@ namespace FFXIVClassic_Map_Server.common StringBuilder sb = new StringBuilder(numLines * lineLength); - for (int i = offset; i < bytes.Length; i += bytesPerLine) - { - line[0] = hexChars[(i >> 28) & 0xF]; - line[1] = hexChars[(i >> 24) & 0xF]; - line[2] = hexChars[(i >> 20) & 0xF]; - line[3] = hexChars[(i >> 16) & 0xF]; - line[4] = hexChars[(i >> 12) & 0xF]; - line[5] = hexChars[(i >> 8) & 0xF]; - line[6] = hexChars[(i >> 4) & 0xF]; - line[7] = hexChars[(i >> 0) & 0xF]; + for (int i = 0; i < bytes.Length; i += bytesPerLine) + { + int h = i + offset; + + line[0] = hexChars[(h >> 28) & 0xF]; + line[1] = hexChars[(h >> 24) & 0xF]; + line[2] = hexChars[(h >> 20) & 0xF]; + line[3] = hexChars[(h >> 16) & 0xF]; + line[4] = hexChars[(h >> 12) & 0xF]; + line[5] = hexChars[(h >> 8) & 0xF]; + line[6] = hexChars[(h >> 4) & 0xF]; + line[7] = hexChars[(h >> 0) & 0xF]; int hexColumn = offsetBlock; int charColumn = byteBlock; diff --git a/FFXIVClassic Map Server/packets/SubPacket.cs b/FFXIVClassic Map Server/packets/SubPacket.cs index ebf8c78c..0fba8242 100644 --- a/FFXIVClassic Map Server/packets/SubPacket.cs +++ b/FFXIVClassic Map Server/packets/SubPacket.cs @@ -147,12 +147,12 @@ namespace FFXIVClassic_Map_Server.packets if (header.type == 0x03) { 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("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE))); } - Console.BackgroundColor = ConsoleColor.DarkMagenta; - - Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE))); - Console.BackgroundColor = ConsoleColor.Black; #endif }