diff --git a/FFXIVClassic Lobby Server/ClientConnection.cs b/FFXIVClassic Lobby Server/ClientConnection.cs index fb103a5b..68da5ee3 100644 --- a/FFXIVClassic Lobby Server/ClientConnection.cs +++ b/FFXIVClassic Lobby Server/ClientConnection.cs @@ -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)); } } } diff --git a/FFXIVClassic Lobby Server/Database.cs b/FFXIVClassic Lobby Server/Database.cs index fcf706d9..ca8361db 100644 --- a/FFXIVClassic Lobby Server/Database.cs +++ b/FFXIVClassic Lobby Server/Database.cs @@ -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 getServers() @@ -335,7 +335,7 @@ namespace FFXIVClassic_Lobby_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); worldList = new List(); } 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(); } finally { @@ -540,7 +540,7 @@ namespace FFXIVClassic_Lobby_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); retainerList = new List(); } finally { diff --git a/FFXIVClassic Lobby Server/PacketProcessor.cs b/FFXIVClassic Lobby Server/PacketProcessor.cs index 075fb89b..8601dd3b 100644 --- a/FFXIVClassic Lobby Server/PacketProcessor.cs +++ b/FFXIVClassic Lobby Server/PacketProcessor.cs @@ -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 accountList = new List(); 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 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 subPackets = characterlistPacket.buildPackets(); diff --git a/FFXIVClassic Lobby Server/Program.cs b/FFXIVClassic Lobby Server/Program.cs index e4052bf9..f99bd6e8 100644 --- a/FFXIVClassic Lobby Server/Program.cs +++ b/FFXIVClassic Lobby Server/Program.cs @@ -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(); } diff --git a/FFXIVClassic Lobby Server/Server.cs b/FFXIVClassic Lobby Server/Server.cs index 501767ef..929e2d8a 100644 --- a/FFXIVClassic Lobby Server/Server.cs +++ b/FFXIVClassic Lobby Server/Server.cs @@ -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) { diff --git a/FFXIVClassic Lobby Server/common/Log.cs b/FFXIVClassic Lobby Server/common/Log.cs index d8eb72ce..c5bb6cf8 100644 --- a/FFXIVClassic Lobby Server/common/Log.cs +++ b/FFXIVClassic Lobby Server/common/Log.cs @@ -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()); } } } diff --git a/FFXIVClassic Lobby Server/common/Utils.cs b/FFXIVClassic Lobby Server/common/Utils.cs index a1f76626..6c5a6aef 100644 --- a/FFXIVClassic Lobby Server/common/Utils.cs +++ b/FFXIVClassic Lobby Server/common/Utils.cs @@ -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 ""; - 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() diff --git a/FFXIVClassic Lobby Server/dataobjects/CharaInfo.cs b/FFXIVClassic Lobby Server/dataobjects/CharaInfo.cs index 3fe9c869..746c7568 100644 --- a/FFXIVClassic Lobby Server/dataobjects/CharaInfo.cs +++ b/FFXIVClassic Lobby Server/dataobjects/CharaInfo.cs @@ -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('/', '_'); } diff --git a/FFXIVClassic Lobby Server/dataobjects/Character.cs b/FFXIVClassic Lobby Server/dataobjects/Character.cs index 91a4f597..5789009f 100644 --- a/FFXIVClassic Lobby Server/dataobjects/Character.cs +++ b/FFXIVClassic Lobby Server/dataobjects/Character.cs @@ -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(); diff --git a/FFXIVClassic Lobby Server/packets/BasePacket.cs b/FFXIVClassic Lobby Server/packets/BasePacket.cs index e5ee3402..d4ee5a2f 100644 --- a/FFXIVClassic Lobby Server/packets/BasePacket.cs +++ b/FFXIVClassic Lobby Server/packets/BasePacket.cs @@ -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; diff --git a/FFXIVClassic Lobby Server/packets/SubPacket.cs b/FFXIVClassic Lobby Server/packets/SubPacket.cs index c55353b2..3d988135 100644 --- a/FFXIVClassic Lobby Server/packets/SubPacket.cs +++ b/FFXIVClassic Lobby Server/packets/SubPacket.cs @@ -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 } diff --git a/FFXIVClassic Map Server/ClientConnection.cs b/FFXIVClassic Map Server/ClientConnection.cs index 77c170f4..9acf0918 100644 --- a/FFXIVClassic Map Server/ClientConnection.cs +++ b/FFXIVClassic Map Server/ClientConnection.cs @@ -46,7 +46,7 @@ namespace FFXIVClassic_Map_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)); } } } diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 0a73d3c7..d2ca6d24 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -116,7 +116,7 @@ namespace FFXIVClassic_Map_Server { if (client != null) client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false)); - Log.error("Zone does not exist or setting isn't valid."); + Log.Error("Zone does not exist or setting isn't valid."); } if (client != null) @@ -142,7 +142,7 @@ namespace FFXIVClassic_Map_Server foreach (KeyValuePair entry in mConnectedPlayerList) { Player p = entry.Value.getActor(); - Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); + Log.Info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); } } } @@ -578,7 +578,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not change weather: " + e); + Log.Error("Could not change weather: " + e); } } #endregion @@ -597,7 +597,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not load packet: " + e); + Log.Error("Could not load packet: " + e); } } #endregion @@ -607,7 +607,7 @@ namespace FFXIVClassic_Map_Server { if (client != null) { - Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); + Log.Info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); client.getActor().zone.clear(); client.getActor().zone.addActorToZone(client.getActor()); client.getActor().sendInstanceUpdate(); @@ -621,11 +621,11 @@ namespace FFXIVClassic_Map_Server #region !reloaditems else if (split[0].Equals("reloaditems")) { - Log.info(String.Format("Got request to reload item gamedata")); + Log.Info(String.Format("Got request to reload item gamedata")); sendMessage(client, "Reloading Item Gamedata..."); gamedataItems.Clear(); gamedataItems = Database.getItemGamedata(); - Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); + Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count)); sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count)); return true; } @@ -644,7 +644,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not load packet: " + e); + Log.Error("Could not load packet: " + e); } } #endregion @@ -660,7 +660,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not give item."); + Log.Error("Could not give item."); } } #endregion @@ -680,7 +680,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not give item."); + Log.Error("Could not give item."); } } #endregion @@ -703,7 +703,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not remove item."); + Log.Error("Could not remove item."); } } #endregion @@ -718,7 +718,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not give keyitem."); + Log.Error("Could not give keyitem."); } } #endregion @@ -737,7 +737,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not remove keyitem."); + Log.Error("Could not remove keyitem."); } } #endregion @@ -754,7 +754,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not give currency."); + Log.Error("Could not give currency."); } } #endregion @@ -775,7 +775,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not remove currency."); + Log.Error("Could not remove currency."); } } #endregion @@ -793,7 +793,7 @@ namespace FFXIVClassic_Map_Server } catch (Exception e) { - Log.error("Could not change music: " + e); + Log.Error("Could not change music: " + e); } } #endregion diff --git a/FFXIVClassic Map Server/Database.cs b/FFXIVClassic Map Server/Database.cs index c38aa839..b8a01d61 100644 --- a/FFXIVClassic Map Server/Database.cs +++ b/FFXIVClassic Map Server/Database.cs @@ -37,7 +37,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -59,7 +59,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -82,7 +82,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -138,7 +138,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -196,7 +196,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -232,7 +232,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -274,7 +274,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -308,7 +308,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -322,7 +322,7 @@ namespace FFXIVClassic_Map_Server int slot = player.getQuestSlot(quest.actorId); if (slot == -1) { - Log.error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId)); + Log.Error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId)); return; } else @@ -360,7 +360,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -790,7 +790,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -834,7 +834,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -872,7 +872,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -905,7 +905,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -976,7 +976,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -1032,7 +1032,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -1067,7 +1067,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -1107,7 +1107,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -1148,7 +1148,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -1188,7 +1188,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -1225,7 +1225,7 @@ namespace FFXIVClassic_Map_Server if (offset < 0 || offset >= cheevosPacket.achievementFlags.Length) { - Log.error("SQL Error; achievement flag offset id out of range: " + offset); + Log.Error("SQL Error; achievement flag offset id out of range: " + offset); continue; } cheevosPacket.achievementFlags[offset] = true; @@ -1234,7 +1234,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 028cedfb..c3a74735 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server player.setConnection(packet.header.connectionType, client); if (packet.header.connectionType == BasePacket.TYPE_ZONE) - Log.debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress())); + Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress())); else if (packet.header.connectionType == BasePacket.TYPE_CHAT) - Log.debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress())); + Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress())); //Create player actor reply1.debugPrintPacket(); @@ -180,7 +180,7 @@ namespace FFXIVClassic_Map_Server //Chat Received case 0x0003: ChatMessagePacket chatMessage = new ChatMessagePacket(subpacket.data); - Log.info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType)); + Log.Info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType)); subpacket.debugPrintSubPacket(); if (chatMessage.message.StartsWith("!")) @@ -238,7 +238,7 @@ namespace FFXIVClassic_Map_Server player.errorMessage += eventStart.error; if (eventStart.errorIndex == eventStart.errorNum - 1) - Log.error("\n"+player.errorMessage); + Log.Error("\n"+player.errorMessage); break; @@ -268,7 +268,7 @@ namespace FFXIVClassic_Map_Server ownerActor = player.getActor().currentDirector; else { - Log.debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams))); + Log.Debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams))); break; } } @@ -276,7 +276,7 @@ namespace FFXIVClassic_Map_Server LuaEngine.doActorOnEventStarted(player.getActor(), ownerActor, eventStart); - Log.debug(String.Format("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams))); + Log.Debug(String.Format("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams))); break; //Unknown, happens at npc spawn and cutscene play???? case 0x00CE: @@ -285,7 +285,7 @@ namespace FFXIVClassic_Map_Server case 0x012E: subpacket.debugPrintSubPacket(); EventUpdatePacket eventUpdate = new EventUpdatePacket(subpacket.data); - Log.debug(String.Format("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams))); + Log.Debug(String.Format("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams))); //Is it a static actor? If not look in the player's instance Actor updateOwnerActor = Server.getStaticActors(player.getActor().currentEventOwner); @@ -398,7 +398,7 @@ namespace FFXIVClassic_Map_Server //GM Ticket Sent case 0x01D5: GMSupportTicketPacket gmTicket = new GMSupportTicketPacket(subpacket.data); - Log.info("Got GM Ticket: \n" + gmTicket.ticketTitle + "\n" + gmTicket.ticketBody); + Log.Info("Got GM Ticket: \n" + gmTicket.ticketTitle + "\n" + gmTicket.ticketBody); client.queuePacket(BasePacket.createPacket(GMTicketSentResponsePacket.buildPacket(player.actorID, true), true, false)); break; //Request to end ticket @@ -406,7 +406,7 @@ namespace FFXIVClassic_Map_Server client.queuePacket(BasePacket.createPacket(EndGMTicketPacket.buildPacket(player.actorID), true, false)); break; 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)); subpacket.debugPrintSubPacket(); break; } diff --git a/FFXIVClassic Map Server/Program.cs b/FFXIVClassic Map Server/Program.cs index 48e9669b..4198a0d5 100644 --- a/FFXIVClassic Map Server/Program.cs +++ b/FFXIVClassic Map Server/Program.cs @@ -21,14 +21,14 @@ namespace FFXIVClassic_Map_Server if (!ConfigConstants.load()) startServer = false; - Log.info("---------FFXIV 1.0 Map Server---------"); + Log.Info("---------FFXIV 1.0 Map 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("Testing DB connection... "); + Log.Info("Testing DB connection... "); 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 @@ -36,11 +36,11 @@ namespace FFXIVClassic_Map_Server conn.Open(); conn.Close(); - Log.conn("[OK]"); + Log.Status("[OK]"); } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); startServer = false; } } @@ -48,9 +48,9 @@ namespace FFXIVClassic_Map_Server //Check World ID DBWorld thisWorld = Database.getServer(ConfigConstants.DATABASE_WORLDID); if (thisWorld != null) - Log.info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name)); + Log.Info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name)); else - Log.info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed."); + Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed."); //Start server if A-OK if (startServer) @@ -66,7 +66,7 @@ namespace FFXIVClassic_Map_Server } } - Log.info("Press any key to continue..."); + Log.Info("Press any key to continue..."); Console.ReadKey(); } diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index a7e7075a..15d64ec4 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -39,7 +39,7 @@ namespace FFXIVClassic_Map_Server private void connectionHealth() { - Log.info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME)); + Log.Info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME)); while (!killHealthThread) { lock (mConnectedPlayerList) @@ -77,7 +77,7 @@ namespace FFXIVClassic_Map_Server mStaticActors = new StaticActors(STATIC_ACTORS_PATH); gamedataItems = Database.getItemGamedata(); - Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); + Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count)); mWorldManager = new WorldManager(this); mWorldManager.LoadZoneList(); @@ -113,7 +113,7 @@ namespace FFXIVClassic_Map_Server } Console.ForegroundColor = ConsoleColor.White; - Log.debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port)); + Log.Debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port)); Console.ForegroundColor = ConsoleColor.Gray; mProcessor = new PacketProcessor(this, mConnectedPlayerList, mConnectionList); @@ -150,7 +150,7 @@ namespace FFXIVClassic_Map_Server mConnectionList.Add(conn); } - 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)); //Queue recieving of data from the connection conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn); //Queue the accept of the next incomming connection @@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server mConnectionList.Remove(conn); } if (conn.connType == BasePacket.TYPE_ZONE) - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); return; } @@ -261,7 +261,7 @@ namespace FFXIVClassic_Map_Server } else { - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); lock (mConnectionList) { @@ -273,7 +273,7 @@ namespace FFXIVClassic_Map_Server { if (conn.socket != null) { - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); lock (mConnectionList) { diff --git a/FFXIVClassic Map Server/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index a1108c37..b6923ffc 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -67,7 +67,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally @@ -117,7 +117,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -125,7 +125,7 @@ namespace FFXIVClassic_Map_Server } } - Log.info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2)); + Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2)); } public void LoadZoneEntranceList() @@ -170,7 +170,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -178,7 +178,7 @@ namespace FFXIVClassic_Map_Server } } - Log.info(String.Format("Loaded {0} zone spawn locations.", count)); + Log.Info(String.Format("Loaded {0} zone spawn locations.", count)); } public void LoadNPCs() @@ -242,7 +242,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -250,7 +250,7 @@ namespace FFXIVClassic_Map_Server } } - Log.info(String.Format("Loaded {0} npc(s).", count)); + Log.Info(String.Format("Loaded {0} npc(s).", count)); } public void LoadNPCs(uint zoneId) @@ -315,7 +315,7 @@ namespace FFXIVClassic_Map_Server } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -323,7 +323,7 @@ namespace FFXIVClassic_Map_Server } } - Log.info(String.Format("Loaded {0} npc(s).", count)); + Log.Info(String.Format("Loaded {0} npc(s).", count)); } //Moves the actor to the new zone if exists. No packets are sent nor position changed. @@ -354,7 +354,7 @@ namespace FFXIVClassic_Map_Server { if (!zoneEntranceList.ContainsKey(zoneEntrance)) { - Log.error("Given zone entrance was not found: " + zoneEntrance); + Log.Error("Given zone entrance was not found: " + zoneEntrance); return; } @@ -410,7 +410,7 @@ namespace FFXIVClassic_Map_Server { if (!zoneEntranceList.ContainsKey(zoneEntrance)) { - Log.error("Given zone entrance was not found: " + zoneEntrance); + Log.Error("Given zone entrance was not found: " + zoneEntrance); return; } diff --git a/FFXIVClassic Map Server/actors/StaticActors.cs b/FFXIVClassic Map Server/actors/StaticActors.cs index 3f037b47..c2393c3f 100644 --- a/FFXIVClassic Map Server/actors/StaticActors.cs +++ b/FFXIVClassic Map Server/actors/StaticActors.cs @@ -89,9 +89,9 @@ namespace FFXIVClassic_Map_Server.Actors } } catch(FileNotFoundException e) - { Log.error("Could not find staticactors file."); return false; } + { Log.Error("Could not find staticactors file."); return false; } - Log.info(String.Format("Loaded {0} static actors.", mStaticActors.Count())); + Log.Info(String.Format("Loaded {0} static actors.", mStaticActors.Count())); return true; } diff --git a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs index b831a7de..5c417c46 100644 --- a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs +++ b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs @@ -238,7 +238,7 @@ namespace FFXIVClassic_Map_Server.Actors } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index cc1359a9..472745bf 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -642,7 +642,7 @@ namespace FFXIVClassic_Map_Server.Actors Database.savePlayerPlayTime(this); Database.savePlayerPosition(this); - Log.info(String.Format("{0} has been logged out and saved.", this.customDisplayName)); + Log.Info(String.Format("{0} has been logged out and saved.", this.customDisplayName)); } public Area getZone() diff --git a/FFXIVClassic Map Server/actors/quest/Quest.cs b/FFXIVClassic Map Server/actors/quest/Quest.cs index e51beb90..cd889312 100644 --- a/FFXIVClassic Map Server/actors/quest/Quest.cs +++ b/FFXIVClassic Map Server/actors/quest/Quest.cs @@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.Actors { if (bitIndex >= 32) { - Log.error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); + Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); return; } @@ -86,7 +86,7 @@ namespace FFXIVClassic_Map_Server.Actors { if (bitIndex >= 32) { - Log.error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); + Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); return false; } else diff --git a/FFXIVClassic Map Server/common/Log.cs b/FFXIVClassic Map Server/common/Log.cs index b68ea944..3379633f 100644 --- a/FFXIVClassic Map Server/common/Log.cs +++ b/FFXIVClassic Map Server/common/Log.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Text; namespace FFXIVClassic_Map_Server.common { @@ -7,66 +8,64 @@ namespace FFXIVClassic_Map_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); } - private 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()); } } } diff --git a/FFXIVClassic Map Server/common/Utils.cs b/FFXIVClassic Map Server/common/Utils.cs index e4e37cf9..60127881 100644 --- a/FFXIVClassic Map Server/common/Utils.cs +++ b/FFXIVClassic Map Server/common/Utils.cs @@ -19,66 +19,69 @@ namespace FFXIVClassic_Map_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 ""; - 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() @@ -87,8 +90,8 @@ namespace FFXIVClassic_Map_Server.common DateTime currentTime = DateTime.Now; DateTime zuluTime = currentTime.ToUniversalTime(); DateTime unixEpoch = new DateTime(1970, 1, 1); - unixTimeStamp = (UInt32)(zuluTime.Subtract(unixEpoch)).TotalSeconds; - + unixTimeStamp = (UInt32)(zuluTime.Subtract(unixEpoch)).TotalSeconds; + return unixTimeStamp; } @@ -98,8 +101,8 @@ namespace FFXIVClassic_Map_Server.common DateTime currentTime = DateTime.Now; DateTime zuluTime = currentTime.ToUniversalTime(); DateTime unixEpoch = new DateTime(1970, 1, 1); - unixTimeStamp = (UInt64)(zuluTime.Subtract(unixEpoch)).TotalMilliseconds; - + unixTimeStamp = (UInt64)(zuluTime.Subtract(unixEpoch)).TotalMilliseconds; + return unixTimeStamp; } @@ -117,10 +120,10 @@ namespace FFXIVClassic_Map_Server.common public static uint swapEndian(uint input) { - return ((input >> 24) & 0xff) | - ((input << 8) & 0xff0000) | - ((input >> 8) & 0xff00) | - ((input << 24) & 0xff000000); + return ((input >> 24) & 0xff) | + ((input << 8) & 0xff0000) | + ((input >> 8) & 0xff00) | + ((input << 24) & 0xff000000); } public static int swapEndian(int input) @@ -137,78 +140,78 @@ namespace FFXIVClassic_Map_Server.common } public static uint MurmurHash2(string key, uint seed) - { - // 'm' and 'r' are mixing constants generated offline. - // They're not really 'magic', they just happen to work well. - - byte[] data = Encoding.ASCII.GetBytes(key); - const uint m = 0x5bd1e995; - const int r = 24; + { + // 'm' and 'r' are mixing constants generated offline. + // They're not really 'magic', they just happen to work well. + + byte[] data = Encoding.ASCII.GetBytes(key); + const uint m = 0x5bd1e995; + const int r = 24; int len = key.Length; - int dataIndex = len - 4; + int dataIndex = len - 4; + + // Initialize the hash to a 'random' value + + uint h = seed ^ (uint)len; + + // Mix 4 bytes at a time into the hash + + + while (len >= 4) + { + h *= m; - // Initialize the hash to a 'random' value - - uint h = seed ^ (uint)len; - - // Mix 4 bytes at a time into the hash - - - while (len >= 4) - { - h *= m; - - uint k = (uint)BitConverter.ToInt32(data, dataIndex); - k = ((k >> 24) & 0xff) | // move byte 3 to byte 0 - ((k << 8) & 0xff0000) | // move byte 1 to byte 2 - ((k >> 8) & 0xff00) | // move byte 2 to byte 1 - ((k << 24) & 0xff000000); // byte 0 to byte 3 - - k *= m; - k ^= k >> r; - k *= m; - - h ^= k; - - dataIndex -= 4; - len -= 4; - } - - // Handle the last few bytes of the input array - switch (len) - { - case 3: + uint k = (uint)BitConverter.ToInt32(data, dataIndex); + k = ((k >> 24) & 0xff) | // move byte 3 to byte 0 + ((k << 8) & 0xff0000) | // move byte 1 to byte 2 + ((k >> 8) & 0xff00) | // move byte 2 to byte 1 + ((k << 24) & 0xff000000); // byte 0 to byte 3 + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + + dataIndex -= 4; + len -= 4; + } + + // Handle the last few bytes of the input array + switch (len) + { + case 3: h ^= (uint)data[0] << 16; goto case 2; - case 2: - h ^= (uint)data[len-2] << 8; goto case 1; - case 1: - h ^= data[len-1]; - h *= m; - break; - }; - - // Do a few final mixes of the hash to ensure the last few - // bytes are well-incorporated. - - h ^= h >> 13; - h *= m; - h ^= h >> 15; - - return h; + case 2: + h ^= (uint)data[len - 2] << 8; goto case 1; + case 1: + h ^= data[len - 1]; + h *= m; + break; + }; + + // Do a few final mixes of the hash to ensure the last few + // bytes are well-incorporated. + + h ^= h >> 13; + h *= m; + h ^= h >> 15; + + return h; } public static byte[] ConvertBoolArrayToBinaryStream(bool[] array) { - byte[] data = new byte[(array.Length/8)+(array.Length%8 != 0 ? 1 : 0)]; + byte[] data = new byte[(array.Length / 8) + (array.Length % 8 != 0 ? 1 : 0)]; int dataCounter = 0; - for (int i = 0; i < array.Length; i+=8) + for (int i = 0; i < array.Length; i += 8) { for (int bitCount = 0; bitCount < 8; bitCount++) { if (i + bitCount >= array.Length) break; - data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7-bitCount) | data[dataCounter]); + data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7 - bitCount) | data[dataCounter]); } dataCounter++; } @@ -226,7 +229,7 @@ namespace FFXIVClassic_Map_Server.common while (true) { string result = ""; - uint key = (uint)data[offset + 0] << 8 | data[offset+1]; + uint key = (uint)data[offset + 0] << 8 | data[offset + 1]; uint key2 = data[offset + 2]; key = RotateRight(key, 1) & 0xFFFF; key -= 0x22AF; @@ -258,7 +261,7 @@ namespace FFXIVClassic_Map_Server.common offset += 4 + count2; - Log.debug(result); + Log.Debug(result); } } @@ -310,7 +313,7 @@ namespace FFXIVClassic_Map_Server.common } count = count ^ key; - result[3] = (byte) (count & 0xFF); + result[3] = (byte)(count & 0xFF); key += 0x22AF & 0xFFFF; key = RotateLeft(key, 1) & 0xFFFF; @@ -318,9 +321,9 @@ namespace FFXIVClassic_Map_Server.common result[2] = (byte)(key & 0xFF); key += 0x22AF & 0xFFFF; - key = RotateLeft(key, 1) & 0xFFFF; - - + key = RotateLeft(key, 1) & 0xFFFF; + + result[1] = (byte)(key & 0xFF); result[0] = (byte)((key >> 8) & 0xFF); diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index 60b86c5d..1092abac 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server.lua } catch(SyntaxErrorException e) { - Log.error(String.Format("LUAERROR: {0}.", e.DecoratedMessage)); + Log.Error(String.Format("LUAERROR: {0}.", e.DecoratedMessage)); return null; } return script; diff --git a/FFXIVClassic Map Server/packets/BasePacket.cs b/FFXIVClassic Map Server/packets/BasePacket.cs index eac717b6..0f6e0914 100644 --- a/FFXIVClassic Map Server/packets/BasePacket.cs +++ b/FFXIVClassic Map Server/packets/BasePacket.cs @@ -333,8 +333,8 @@ 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("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()))); foreach (SubPacket sub in getSubpackets()) sub.debugPrintSubPacket(); Console.BackgroundColor = ConsoleColor.Black; diff --git a/FFXIVClassic Map Server/packets/SubPacket.cs b/FFXIVClassic Map Server/packets/SubPacket.cs index 4695b5b7..54da7092 100644 --- a/FFXIVClassic Map Server/packets/SubPacket.cs +++ b/FFXIVClassic Map Server/packets/SubPacket.cs @@ -141,14 +141,14 @@ 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}", 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 } diff --git a/FFXIVClassic Map Server/packets/receive/events/EventStartPacket.cs b/FFXIVClassic Map Server/packets/receive/events/EventStartPacket.cs index cd18740a..a9c8c042 100644 --- a/FFXIVClassic Map Server/packets/receive/events/EventStartPacket.cs +++ b/FFXIVClassic Map Server/packets/receive/events/EventStartPacket.cs @@ -48,7 +48,7 @@ namespace FFXIVClassic_Map_Server.packets.receive.events error = ASCIIEncoding.ASCII.GetString(binReader.ReadBytes(0x80)).Replace("\0", ""); if (errorIndex == 0) - Log.error("LUA ERROR:"); + Log.Error("LUA ERROR:"); return; } diff --git a/FFXIVClassic Map Server/packets/send/player/SetCompletedAchievementsPacket.cs b/FFXIVClassic Map Server/packets/send/player/SetCompletedAchievementsPacket.cs index 3ca74b8c..824a067d 100644 --- a/FFXIVClassic Map Server/packets/send/player/SetCompletedAchievementsPacket.cs +++ b/FFXIVClassic Map Server/packets/send/player/SetCompletedAchievementsPacket.cs @@ -36,7 +36,7 @@ namespace FFXIVClassic_Map_Server.packets.send.player if (binStream.Length <= PACKET_SIZE - 0x20) binWriter.Write(binStream); else - Log.error("Failed making SetCompletedAchievements packet. Bin Stream was too big!"); + Log.Error("Failed making SetCompletedAchievements packet. Bin Stream was too big!"); } } diff --git a/FFXIVClassic Map Server/packets/send/player/SetCutsceneBookPacket.cs b/FFXIVClassic Map Server/packets/send/player/SetCutsceneBookPacket.cs index 3e9c4680..f7afa871 100644 --- a/FFXIVClassic Map Server/packets/send/player/SetCutsceneBookPacket.cs +++ b/FFXIVClassic Map Server/packets/send/player/SetCutsceneBookPacket.cs @@ -81,7 +81,7 @@ namespace FFXIVClassic_Map_Server.packets.send.player if (binStream.Length <= PACKET_SIZE - 0x20) binWriter.Write(binStream); else - Log.error("Failed making SetCutsceneBook packet. Bin Stream was too big!"); + Log.Error("Failed making SetCutsceneBook packet. Bin Stream was too big!"); binWriter.Seek(0x109, SeekOrigin.Begin); binWriter.Write(Encoding.ASCII.GetBytes(sNpcName), 0, Encoding.ASCII.GetByteCount(sNpcName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sNpcName)); diff --git a/FFXIVClassic Map Server/utils/SQLGeneration.cs b/FFXIVClassic Map Server/utils/SQLGeneration.cs index ea2f465e..8acb47a9 100644 --- a/FFXIVClassic Map Server/utils/SQLGeneration.cs +++ b/FFXIVClassic Map Server/utils/SQLGeneration.cs @@ -79,14 +79,14 @@ namespace FFXIVClassic_Map_Server.utils cmd.Parameters["@placename"].Value = placenames[pId]; - Log.debug(String.Format("Wrote: {0}", id)); + Log.Debug(String.Format("Wrote: {0}", id)); cmd.ExecuteNonQuery(); } } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -137,14 +137,14 @@ namespace FFXIVClassic_Map_Server.utils cmd.Parameters["@id"].Value = id; cmd.Parameters["@displayNameId"].Value = nameId; - Log.debug(String.Format("Wrote: {0} : {1}", id, nameId)); + Log.Debug(String.Format("Wrote: {0} : {1}", id, nameId)); cmd.ExecuteNonQuery(); } } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -203,14 +203,14 @@ namespace FFXIVClassic_Map_Server.utils cmd.Parameters["@id"].Value = id; - Log.debug(String.Format("Wrote: {0}", id)); + Log.Debug(String.Format("Wrote: {0}", id)); cmd.ExecuteNonQuery(); } } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -288,7 +288,7 @@ namespace FFXIVClassic_Map_Server.utils else if (id == 1500) otherId = SetCompletedAchievementsPacket.CATEGORY_GRAND_COMPANY; - Log.debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points)); + Log.Debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points)); cmd.Parameters["@id"].Value = id; cmd.Parameters["@name"].Value = name; cmd.Parameters["@otherId"].Value = otherId; @@ -300,7 +300,7 @@ namespace FFXIVClassic_Map_Server.utils } catch (MySqlException e) { - Log.error(e.ToString()); + Log.Error(e.ToString()); } finally { @@ -338,7 +338,7 @@ namespace FFXIVClassic_Map_Server.utils string output2 = String.Format("mStaticActors.Add(0x{0:x}, new {2}(0x{0:x}, \"{1}\"));", id, output.Substring(1 + output.LastIndexOf("/")), output.Split('/')[1]); - Log.debug(output2); + Log.Debug(output2); w.WriteLine(output2); }