Cleaned up LogFile and ByteArrayToHex utils.

This commit is contained in:
deviltti
2016-06-10 19:58:01 -04:00
parent 8b93abe86e
commit 1c712c7533
31 changed files with 409 additions and 405 deletions

View File

@@ -59,7 +59,7 @@ namespace FFXIVClassic_Lobby_Server
socket.Send(packetBytes);
}
catch(Exception e)
{ Log.error(String.Format("Weird case, socket was d/ced: {0}", e)); }
{ Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
}
}

View File

@@ -33,7 +33,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
}
finally
@@ -88,9 +88,9 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
Log.error(e.ToString());
Log.Error(e.ToString());
pid = 0;
cid = 0;
@@ -100,7 +100,7 @@ namespace FFXIVClassic_Lobby_Server
conn.Dispose();
}
Log.database(String.Format("CID={0} created on 'characters' table.", cid));
Log.Sql(String.Format("CID={0} created on 'characters' table.", cid));
}
return alreadyExists;
@@ -183,7 +183,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
conn.Dispose();
return;
@@ -208,7 +208,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
conn.Dispose();
return;
@@ -230,7 +230,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
}
@@ -242,7 +242,7 @@ namespace FFXIVClassic_Lobby_Server
}
Log.database(String.Format("CID={0} state updated to active(2).", cid));
Log.Sql(String.Format("CID={0} state updated to active(2).", cid));
}
public static bool renameCharacter(uint userId, uint characterId, uint serverId, String newName)
@@ -277,7 +277,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
}
@@ -286,7 +286,7 @@ namespace FFXIVClassic_Lobby_Server
conn.Dispose();
}
Log.database(String.Format("CID={0} name updated to \"{1}\".", characterId, newName));
Log.Sql(String.Format("CID={0} name updated to \"{1}\".", characterId, newName));
return false;
}
@@ -310,7 +310,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
}
@@ -320,7 +320,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
Log.database(String.Format("CID={0} deleted.", characterId));
Log.Sql(String.Format("CID={0} deleted.", characterId));
}
public static List<World> getServers()
@@ -335,7 +335,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
worldList = new List<World>(); }
finally
{
@@ -357,7 +357,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
}
finally
@@ -494,7 +494,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
}
finally
@@ -518,7 +518,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
nameList = new List<String>(); }
finally
{
@@ -540,7 +540,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.Error(e.ToString());
retainerList = new List<Retainer>(); }
finally
{

View File

@@ -53,7 +53,7 @@ namespace FFXIVClassic_Lobby_Server
case 0x0F:
//Mod Retainers
default:
Log.debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
break;
}
}
@@ -67,7 +67,7 @@ namespace FFXIVClassic_Lobby_Server
byte[] blowfishKey = GenerateKey(securityHandshake.ticketPhrase, securityHandshake.clientNumber);
client.blowfish = new Blowfish(blowfishKey);
Log.info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber));
Log.Info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber));
//Respond with acknowledgment
BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment);
@@ -81,8 +81,8 @@ namespace FFXIVClassic_Lobby_Server
SessionPacket sessionPacket = new SessionPacket(packet.data);
String clientVersion = sessionPacket.version;
Log.info(String.Format("Got acknowledgment for secure session."));
Log.info(String.Format("CLIENT VERSION: {0}", clientVersion));
Log.Info(String.Format("Got acknowledgment for secure session."));
Log.Info(String.Format("CLIENT VERSION: {0}", clientVersion));
uint userId = Database.getUserIdFromSession(sessionPacket.session);
client.currentUserId = userId;
@@ -96,11 +96,11 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, errorBasePacket);
client.queuePacket(errorBasePacket);
Log.info(String.Format("Invalid session, kicking..."));
Log.Info(String.Format("Invalid session, kicking..."));
return;
}
Log.info(String.Format("USER ID: {0}", userId));
Log.Info(String.Format("USER ID: {0}", userId));
List<Account> accountList = new List<Account>();
Account defaultAccount = new Account();
@@ -115,7 +115,7 @@ namespace FFXIVClassic_Lobby_Server
private void ProcessGetCharacters(ClientConnection client, SubPacket packet)
{
Log.info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId));
Log.Info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId));
sendWorldList(client, packet);
sendImportList(client, packet);
@@ -128,7 +128,7 @@ namespace FFXIVClassic_Lobby_Server
{
SelectCharacterPacket selectCharRequest = new SelectCharacterPacket(packet.data);
Log.info(String.Format("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId));
Log.Info(String.Format("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId));
Character chara = Database.getCharacter(client.currentUserId, selectCharRequest.characterId);
World world = null;
@@ -187,7 +187,7 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
Log.info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId));
Log.Info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId));
return;
}
@@ -207,7 +207,7 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
Log.info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
return;
}
else
@@ -219,7 +219,7 @@ namespace FFXIVClassic_Lobby_Server
client.newCharaName = name;
}
Log.info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name));
Log.Info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name));
break;
case 0x02://Make
CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded);
@@ -272,7 +272,7 @@ namespace FFXIVClassic_Lobby_Server
cid = client.newCharaCid;
name = client.newCharaName;
Log.info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name));
Log.Info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name));
break;
case 0x03://Rename
@@ -286,20 +286,20 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
Log.info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
return;
}
Log.info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name));
Log.Info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name));
break;
case 0x04://Delete
Database.deleteCharacter(charaReq.characterId, charaReq.characterName);
Log.info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name));
Log.Info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name));
break;
case 0x06://Rename Retainer
Log.info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name));
Log.Info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name));
break;
}
@@ -349,7 +349,7 @@ namespace FFXIVClassic_Lobby_Server
List<Character> characterList = Database.getCharacters(client.currentUserId);
if (characterList.Count > 8)
Log.error("Warning, got more than 8 characters. List truncated, check DB for issues.");
Log.Error("Warning, got more than 8 characters. List truncated, check DB for issues.");
CharacterListPacket characterlistPacket = new CharacterListPacket(0, characterList);
List<SubPacket> subPackets = characterlistPacket.buildPackets();

View File

@@ -22,15 +22,15 @@ namespace FFXIVClassic_Lobby_Server
if (!ConfigConstants.load())
startServer = false;
Log.log("--------FFXIV 1.0 Lobby Server--------", Log.LogType.Debug);
Log.Info("--------FFXIV 1.0 Lobby Server--------");
Assembly assem = Assembly.GetExecutingAssembly();
Version vers = assem.GetName().Version;
Log.info("Version: " + vers.ToString());
Log.Info("Version: " + vers.ToString());
//Test DB Connection
Log.info(String.Format("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST));
Log.Info(String.Format("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST));
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
@@ -38,12 +38,12 @@ namespace FFXIVClassic_Lobby_Server
conn.Open();
conn.Close();
Log.conn("[OK]");
Log.Status("[OK]");
}
catch (MySqlException e)
{
Log.error(e.ToString());
Log.error("[FAILED]");
Log.Error(e.ToString());
Log.Error("[FAILED]");
startServer = false;
}
@@ -58,7 +58,7 @@ namespace FFXIVClassic_Lobby_Server
while (true) Thread.Sleep(10000);
}
Log.info("Press any key to continue...");
Log.Info("Press any key to continue...");
Console.ReadKey();
}

View File

@@ -25,7 +25,7 @@ namespace FFXIVClassic_Lobby_Server
private void socketCleanup()
{
Log.debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
Log.Debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
while (!killCleanupThread)
{
int count = 0;
@@ -40,7 +40,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
if (count != 0)
Log.conn(String.Format("{0} connections were cleaned up.", count));
Log.Status(String.Format("{0} connections were cleaned up.", count));
Thread.Sleep(CLEANUP_THREAD_SLEEP_TIME*1000);
}
}
@@ -80,7 +80,7 @@ namespace FFXIVClassic_Lobby_Server
}
Console.ForegroundColor = ConsoleColor.White;
Log.debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Log.Debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Console.ForegroundColor = ConsoleColor.Gray;
mProcessor = new PacketProcessor();
@@ -105,7 +105,7 @@ namespace FFXIVClassic_Lobby_Server
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
//Queue the accept of the next incomming connection
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
Log.conn(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
}
catch (SocketException)
{
@@ -179,7 +179,7 @@ namespace FFXIVClassic_Lobby_Server
}
else
{
Log.conn(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
lock (mConnectionList)
{
@@ -192,7 +192,7 @@ namespace FFXIVClassic_Lobby_Server
{
if (conn.socket != null)
{
Log.conn(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
lock (mConnectionList)
{

View File

@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Text;
namespace FFXIVClassic_Lobby_Server.common
{
@@ -7,66 +8,64 @@ namespace FFXIVClassic_Lobby_Server.common
{
public enum LogType
{
Error = ConsoleColor.Red,
Debug = ConsoleColor.Yellow,
Info = ConsoleColor.Cyan,
Status = ConsoleColor.Green,
Sql = ConsoleColor.Magenta,
Conn = ConsoleColor.Green,
Default = ConsoleColor.Gray
Info = ConsoleColor.White,
Debug = ConsoleColor.Cyan,
Error = ConsoleColor.Red
}
public static void error(String message)
public static void Status(String message)
{
log(message, LogType.Error);
LogFile(message, LogType.Status);
}
public static void debug(String message)
public static void Sql(String message)
{
#if DEBUG
log(message, LogType.Debug);
#endif
LogFile(message, LogType.Sql);
}
public static void info(String message)
public static void Info(String message)
{
log(message, LogType.Info);
LogFile(message, LogType.Info);
}
public static void database(String message)
public static void Debug(String message)
{
log(message, LogType.Sql);
#if DEBUG
LogFile(message, LogType.Debug);
#endif
}
public static void conn(String message)
public static void Error(String message)
{
log(message, LogType.Conn);
LogFile(message, LogType.Error);
}
public static void log(String message, LogType type)
private static void LogFile(String message, LogType type)
{
var timestamp = String.Format("[{0}] ", DateTime.Now.ToString("dd/MMM HH:mm:ss"));
var typestr = String.Format("[{0}] ", type.ToString().ToUpper());
string timestamp = String.Format("[{0}]", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
string messageType = String.Format("[{0}] ", type.ToString().ToUpper());
Console.Write(timestamp);
Console.WriteLine(timestamp);
Console.ForegroundColor = (ConsoleColor)type;
Console.Write(typestr);
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(message);
Console.Write(messageType);
Console.ResetColor();
Console.Write(message);
message = message.Insert(0, typestr);
message = message.Insert(0, timestamp);
StringBuilder sb = new StringBuilder();
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
sb.AppendLine(String.Format("{0}{1}{2}", timestamp, messageType, message));
try
if (!Directory.Exists(ConfigConstants.OPTIONS_LOGPATH))
{
File.AppendAllText(ConfigConstants.OPTIONS_LOGPATH + ConfigConstants.OPTIONS_LOGFILE, message + Environment.NewLine);
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
}
catch (Exception e)
using (FileStream fs = new FileStream(Path.Combine(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE), FileMode.Append, FileAccess.Write))
using (StreamWriter sw = new StreamWriter(fs))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(e.Message);
Console.ForegroundColor = ConsoleColor.Gray;
sw.WriteLine(sb.ToString());
}
}
}

View File

@@ -18,66 +18,69 @@ namespace FFXIVClassic_Lobby_Server.common
return result;
}
public static string ByteArrayToHex(byte[] bytes)
public static string ByteArrayToHex(byte[] bytes, int offset = 0, int bytesPerLine = 16)
{
if (bytes == null) return "<null>";
int bytesLength = bytes.Length;
var bytesPerLine = 16;
char[] HexChars = "0123456789ABCDEF".ToCharArray();
int firstHexColumn =
8 // 8 characters for the address
+ 3; // 3 spaces
int firstCharColumn = firstHexColumn
+ bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space
+ (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
+ 2; // 2 spaces
int lineLength = firstCharColumn
+ bytesPerLine // - characters to show the ascii value
+ Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
StringBuilder result = new StringBuilder(expectedLines * lineLength);
for (int i = 0; i < bytesLength; i += bytesPerLine)
if (bytes == null)
{
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];
return String.Empty;
}
char[] hexChars = "0123456789ABCDEF".ToCharArray();
int hexColumn = firstHexColumn;
int charColumn = firstCharColumn;
// 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
// 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
int offsetBlock = 8 + 3;
int byteBlock = offsetBlock + (bytesPerLine * 3) + ((bytesPerLine - 1) / 8) + 2;
int lineLength = byteBlock + bytesPerLine + Environment.NewLine.Length;
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
int numLines = (bytes.Length + bytesPerLine - 1) / bytesPerLine;
for (int j = 0; j < bytesPerLine; j++)
{
if (j > 0 && (j & 7) == 0) hexColumn++;
if (i + j >= bytesLength)
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];
int hexColumn = offsetBlock;
int charColumn = byteBlock;
for (int j = 0; j < bytesPerLine; j++)
{
if (j > 0 && (j & 7) == 0)
{
line[hexColumn] = ' ';
line[hexColumn + 1] = ' ';
line[charColumn] = ' ';
hexColumn++;
}
else
{
byte b = bytes[i + j];
line[hexColumn] = HexChars[(b >> 4) & 0xF];
line[hexColumn + 1] = HexChars[b & 0xF];
line[charColumn] = (b < 32 ? '.' : (char)b);
if (i + j >= bytes.Length)
{
line[hexColumn] = ' ';
line[hexColumn + 1] = ' ';
line[charColumn] = ' ';
}
else
{
byte by = bytes[i + j];
line[hexColumn] = hexChars[(by >> 4) & 0xF];
line[hexColumn + 1] = hexChars[by & 0xF];
line[charColumn] = (by < 32 ? '.' : (char)by);
}
hexColumn += 3;
charColumn++;
}
result.Append(line);
}
return Environment.NewLine + result.ToString();
hexColumn += 3;
charColumn++;
}
sb.Append(line);
}
return sb.ToString();
}
public static UInt32 UnixTimeStampUTC()

View File

@@ -227,7 +227,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
{
byte[] bytes = File.ReadAllBytes("./packets/charaappearance.bin");
Log.debug(Utils.ByteArrayToHex(bytes));
Log.Debug(Utils.ByteArrayToHex(bytes));
return Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_');
}

View File

@@ -33,9 +33,9 @@ namespace FFXIVClassic_Lobby_Server
charaInfo.Replace("/", "_");
byte[] data = System.Convert.FromBase64String(charaInfo);
Log.debug("------------Base64 printout------------------");
Log.debug(Utils.ByteArrayToHex(data));
Log.debug("------------Base64 printout------------------");
Log.Debug("------------Base64 printout------------------");
Log.Debug(Utils.ByteArrayToHex(data));
Log.Debug("------------Base64 printout------------------");
CharaInfo chara = new CharaInfo();

View File

@@ -335,8 +335,8 @@ 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("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())));
foreach (SubPacket sub in getSubpackets())
sub.debugPrintSubPacket();
Console.BackgroundColor = ConsoleColor.Black;

View File

@@ -141,14 +141,14 @@ 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}", header.subpacketSize));
if (header.type == 0x03)
Log.debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode));
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
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("{0}", Utils.ByteArrayToHex(getGameMessageBytes())));
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(data)));
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(data)));
Console.BackgroundColor = ConsoleColor.Black;
#endif
}