Exemplo n.º 1
0
        public void LoadConfig()
        {
            // DONE: Setting SQL Connections
            var accountDbSettings = Strings.Split(configurationProvider.GetConfiguration().AccountDatabase, ";");

            if (accountDbSettings.Length != 6)
            {
                Console.WriteLine("Invalid connect string for the account database!");
            }
            else
            {
                GetAccountDatabase().SQLDBName     = accountDbSettings[4];
                GetAccountDatabase().SQLHost       = accountDbSettings[2];
                GetAccountDatabase().SQLPort       = accountDbSettings[3];
                GetAccountDatabase().SQLUser       = accountDbSettings[0];
                GetAccountDatabase().SQLPass       = accountDbSettings[1];
                GetAccountDatabase().SQLTypeServer = (SQL.DB_Type)Enum.Parse(typeof(SQL.DB_Type), accountDbSettings[5]);
            }

            var characterDbSettings = Strings.Split(configurationProvider.GetConfiguration().CharacterDatabase, ";");

            if (characterDbSettings.Length != 6)
            {
                Console.WriteLine("Invalid connect string for the character database!");
            }
            else
            {
                GetCharacterDatabase().SQLDBName     = characterDbSettings[4];
                GetCharacterDatabase().SQLHost       = characterDbSettings[2];
                GetCharacterDatabase().SQLPort       = characterDbSettings[3];
                GetCharacterDatabase().SQLUser       = characterDbSettings[0];
                GetCharacterDatabase().SQLPass       = characterDbSettings[1];
                GetCharacterDatabase().SQLTypeServer = (SQL.DB_Type)Enum.Parse(typeof(SQL.DB_Type), characterDbSettings[5]);
            }

            var worldDbSettings = Strings.Split(configurationProvider.GetConfiguration().WorldDatabase, ";");

            if (worldDbSettings.Length != 6)
            {
                Console.WriteLine("Invalid connect string for the world database!");
            }
            else
            {
                GetWorldDatabase().SQLDBName     = worldDbSettings[4];
                GetWorldDatabase().SQLHost       = worldDbSettings[2];
                GetWorldDatabase().SQLPort       = worldDbSettings[3];
                GetWorldDatabase().SQLUser       = worldDbSettings[0];
                GetWorldDatabase().SQLPass       = worldDbSettings[1];
                GetWorldDatabase().SQLTypeServer = (SQL.DB_Type)Enum.Parse(typeof(SQL.DB_Type), worldDbSettings[5]);
            }

            // DONE: Creating logger
            Log          = BaseWriter.CreateLog(configurationProvider.GetConfiguration().LogType, configurationProvider.GetConfiguration().LogConfig);
            Log.LogLevel = configurationProvider.GetConfiguration().LogLevel;

            // DONE: Cleaning up the packet log
            if (configurationProvider.GetConfiguration().PacketLogging)
            {
                File.Delete("packets.log");
            }
        }
Exemplo n.º 2
0
        public void LoadConfig()
        {
            try
            {
                string   FileName = "configs/WorldServer.ini";
                string[] args     = Environment.GetCommandLineArgs();
                string[] array    = args;
                foreach (var arg in from string arg in array
                         where arg.IndexOf("config") != -1
                         select arg)
                {
                    FileName = Strings.Trim(arg.Substring(checked (arg.IndexOf("=") + 1)));
                }

                if (!File.Exists(FileName))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("[{0}] Cannot Continue. {1} does not exist.", Strings.Format(DateAndTime.TimeOfDay, "hh:mm:ss"), FileName);
                    Console.WriteLine("Please copy the ini files into the same directory as the Server exe files.");
                    Console.WriteLine("Press any key to exit server: ");
                    Console.ReadKey();
                    ProjectData.EndApp();
                }
                Console.Write("[{0}] Loading Configuration from {1}...", Strings.Format(DateAndTime.TimeOfDay, "hh:mm:ss"), FileName);
                WorldServerConfiguration configuration = WorldServiceLocator._ConfigurationProvider.GetConfiguration();
                Console.WriteLine(".[done]");
                if (!configuration.VMapsEnabled)
                {
                    configuration.LineOfSightEnabled = false;
                    configuration.HeightCalcEnabled  = false;
                }
                string[] AccountDBSettings = Strings.Split(configuration.AccountDatabase, ";");
                if (AccountDBSettings.Length == 6)
                {
                    AccountDatabase.SQLDBName     = AccountDBSettings[4];
                    AccountDatabase.SQLHost       = AccountDBSettings[2];
                    AccountDatabase.SQLPort       = AccountDBSettings[3];
                    AccountDatabase.SQLUser       = AccountDBSettings[0];
                    AccountDatabase.SQLPass       = AccountDBSettings[1];
                    AccountDatabase.SQLTypeServer = (SQL.DB_Type)Conversions.ToInteger(Enum.Parse(typeof(SQL.DB_Type), AccountDBSettings[5]));
                }
                else
                {
                    Console.WriteLine("Invalid connect string for the account database!");
                }
                string[] CharacterDBSettings = Strings.Split(configuration.CharacterDatabase, ";");
                if (CharacterDBSettings.Length == 6)
                {
                    CharacterDatabase.SQLDBName     = CharacterDBSettings[4];
                    CharacterDatabase.SQLHost       = CharacterDBSettings[2];
                    CharacterDatabase.SQLPort       = CharacterDBSettings[3];
                    CharacterDatabase.SQLUser       = CharacterDBSettings[0];
                    CharacterDatabase.SQLPass       = CharacterDBSettings[1];
                    CharacterDatabase.SQLTypeServer = (SQL.DB_Type)Conversions.ToInteger(Enum.Parse(typeof(SQL.DB_Type), CharacterDBSettings[5]));
                }
                else
                {
                    Console.WriteLine("Invalid connect string for the character database!");
                }
                string[] WorldDBSettings = Strings.Split(configuration.WorldDatabase, ";");
                if (WorldDBSettings.Length == 6)
                {
                    WorldDatabase.SQLDBName     = WorldDBSettings[4];
                    WorldDatabase.SQLHost       = WorldDBSettings[2];
                    WorldDatabase.SQLPort       = WorldDBSettings[3];
                    WorldDatabase.SQLUser       = WorldDBSettings[0];
                    WorldDatabase.SQLPass       = WorldDBSettings[1];
                    WorldDatabase.SQLTypeServer = (SQL.DB_Type)Conversions.ToInteger(Enum.Parse(typeof(SQL.DB_Type), WorldDBSettings[5]));
                }
                else
                {
                    Console.WriteLine("Invalid connect string for the world database!");
                }
                WorldServiceLocator._WS_Maps.RESOLUTION_ZMAP = checked (configuration.MapResolution - 1);
                if (WorldServiceLocator._WS_Maps.RESOLUTION_ZMAP < 63)
                {
                    WorldServiceLocator._WS_Maps.RESOLUTION_ZMAP = 63;
                }
                if (WorldServiceLocator._WS_Maps.RESOLUTION_ZMAP > 255)
                {
                    WorldServiceLocator._WS_Maps.RESOLUTION_ZMAP = 255;
                }
                Log          = BaseWriter.CreateLog(configuration.LogType, configuration.LogConfig);
                Log.LogLevel = configuration.LogLevel;
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception e = ex;
                Console.WriteLine(e.ToString());
                ProjectData.ClearProjectError();
            }
        }