/// <summary> /// Inicializa o servidor /// </summary> public void InitializeServer() { trayIcon = new NotifyIcon(); trayMenu = new ContextMenu(); LuaScript.LuaConfig.InitializeConfig(); Configuration.ParseConfigFile($"{Environment.CurrentDirectory}\\{Settings.FILE_CONFIG}"); Settings.Discovery = Configuration.GetString("Discovery"); WriteLog($"Discovery: {Settings.Discovery}", Color.Black); Settings.Port = Configuration.GetInt32("Port"); WriteLog($"Port: {Settings.Port}", Color.Black); Settings.MaxConnection = Configuration.GetInt32("MaximumConnections"); WriteLog($"MaxConnection: {Settings.MaxConnection}", Color.Black); Settings.ConnectionTimeOut = Configuration.GetInt32("ConnectionTimeOut"); WriteLog($"ConnectionTimeOut: {Settings.ConnectionTimeOut}", Color.Black); Settings.LogSystem = Configuration.GetByte("LogSystem"); WriteLog($"LogSystem: {Settings.LogSystem}", Color.Black); Settings.Sleep = Configuration.GetInt32("Sleep"); WriteLog($"Sleep: {Settings.Sleep}", Color.Black); Settings.Version = Configuration.GetString("CheckVersion"); WriteLog($"Version: {Settings.Version}", Color.BlueViolet); GeoIp.Enabled = Configuration.GetBoolean("GeoIp"); var result = (GeoIp.Enabled == true) ? "Ativado" : "Desativado"; WriteLog($"GeoIp: {result}", Color.BlueViolet); CheckSum.Enabled = Configuration.GetBoolean("CheckSum"); result = (CheckSum.Enabled == true) ? "Ativado" : "Desativado"; WriteLog($"CheckSum: {result}", Color.BlueViolet); //1 - enabled result = (Settings.LogSystem == 1) ? "LogSystem: Ativado" : "LogSystem: Desativado"; WriteLog("LogSystem: Desativado.", Color.Black); if (Settings.LogSystem == 1) { FileLog.OpenFileLog(); } Authentication.Player = new HashSet <PlayerData>(); InitializeServerConfig(); InitializeDatabaseConfig(); var tempError = string.Empty; if (!Common_DB.Open(out tempError)) { WriteLog(tempError, Color.Red); } else { WriteLog("Connectado ao banco de dados", Color.Green); } WriteLog("Conectando World Server.", Color.Green); WorldNetwork.InitializeWorldServer(); WriteLog("Login Server Start.", Color.Green); LoginNetwork.InitializeServer(); GeoIp.ReadFile(); #region Tray System trayMenu.MenuItems.Add("Mostrar", ShowForm); trayMenu.MenuItems.Add("Sair", quit_MenuItem_Click); trayIcon.Text = "Connect Server @"; trayIcon.Icon = this.Icon; trayIcon.ContextMenu = trayMenu; #endregion }
public void InitializeServer() { trayIcon = new NotifyIcon(); trayMenu = new ContextMenu(); Configuration.ParseConfigFile(Settings.FILE_CONFIG); // CARREGA TODAS AS INFORMAÇÕES DE CONFIURAÇÃO Settings.WorldServerName = Configuration.GetString("WorldServerName"); WriteLog($"World Server Name: {Settings.WorldServerName}", Color.CornflowerBlue); Text = $"World Server @ {Settings.WorldServerName}"; Settings.Discovery = Configuration.GetString("Discovery"); WriteLog($"Discovery: {Settings.Discovery}", Color.Black); Settings.Port = Configuration.GetInt32("Port"); WriteLog($"Port: {Settings.Port}", Color.Black); Settings.MaxConnection = Configuration.GetInt32("MaximumConnections"); WriteLog($"MaxConnection: {Settings.MaxConnection}", Color.Black); Settings.ConnectionTimeOut = Configuration.GetInt32("ConnectionTimeOut"); WriteLog($"ConnectionTimeOut: {Settings.ConnectionTimeOut}", Color.Black); Settings.LogSystem = Configuration.GetBoolean("LogSystem"); WriteLog($"LogSystem: {Settings.LogSystem}", Color.Black); Settings.Sleep = Configuration.GetInt32("Sleep"); WriteLog($"Sleep: {Settings.Sleep}", Color.Black); LuaConfig.InitializeConfig(); WriteLog($"Create Character: {GameSettings.CharacterCreation}", Color.MediumVioletRed); WriteLog($"Delete Character: {GameSettings.CharacterDelete}", Color.MediumVioletRed); InitializeServerConfig(); if (Settings.LogSystem == true) { WriteLog("LogSystem - Ativado.", Color.Green); FileLog.Open(); } else { WriteLog("LogSystem - Desativado.", Color.Black); } WriteLog("Carregando config do mysql", Color.Black); string tempError = string.Empty; Common_DB.Server = Configuration.GetString("MySQL_IP"); Common_DB.Port = Configuration.GetInt32("MySQL_Port"); Common_DB.Username = Configuration.GetString("MySQL_User"); Common_DB.Password = Configuration.GetString("MySQL_Pass"); Common_DB.Database = Configuration.GetString("MySQL_DB"); // Tenta fazer a conexão com o banco de dados if (!Common_DB.Open(out tempError)) { WriteLog(tempError, Color.Red); } else { WriteLog("Connectado ao banco de dados", Color.Green); } Authentication.HexID = new HashSet <HexaID>(); Authentication.Player = new HashSet <PlayerData>(); InitializeGuild(); InitializeClasse(); WorldNetwork.InitializeServer(); GameNetwork.InitializeGameServer(); WriteLog("World Server Start.", Color.Green); //################# sysTray ######################## trayMenu.MenuItems.Add("Mostrar", ShowForm); trayMenu.MenuItems.Add("Sair", quit_MenuItem_Click); trayIcon.Text = "World Server @"; trayIcon.Icon = this.Icon; trayIcon.ContextMenu = trayMenu; }