示例#1
0
        private void Boot()
        {
            this.writeInfo();
            this.writeBlank();
            Logging.logHolyInfo("Starting up...");
            Logging.logHolyInfo("Checking settings.ini...");
            Application.DoEvents();

            string settingFilePath = Filesystem.startupPath + @"\settings.ini";

            if (!Filesystem.fileExists(settingFilePath))
            {
                Logging.logHolyInfo("File 'settings.ini' wasn't present at " + settingFilePath + ".");
                Logging.logHolyInfo("System is going to use default settings.");
                this.writeBlank();
                Application.DoEvents();
            }
            else
            {
                Logging.logHolyInfo("settings.ini found. (" + settingFilePath + ")");
                this.writeBlank();
                Application.DoEvents();

                Settings.mysql_host     = Filesystem.readINI("mysql", "host", settingFilePath);
                Settings.mysql_username = Filesystem.readINI("mysql", "username", settingFilePath);
                Settings.mysql_password = Filesystem.readINI("mysql", "password", settingFilePath);
                Settings.mysql_db       = Filesystem.readINI("mysql", "database", settingFilePath);
                Settings.mysql_port     = int.Parse(Filesystem.readINI("mysql", "port", settingFilePath));
            }

            if (!Database.openConnection(Settings.mysql_host, Settings.mysql_username, Settings.mysql_password, Settings.mysql_db, Settings.mysql_port))
            {
                this.Shutdown();
                return;
            }
            this.writeBlank();
            Application.DoEvents();

            Settings.Init();
            this.writeBlank();
            Database.runQuery("UPDATE servers SET max = '" + Settings.server_max_connections + "' WHERE name = '" + Settings.server_name + "'");
            Application.DoEvents();

            Preloader.Init();
            this.writeBlank();
            Application.DoEvents();

            if (!Sockets.Listen(Settings.server_port, Settings.server_max_connections, Settings.server_back_log))
            {
                this.Shutdown();
                return;
            }
            this.writeBlank();
            Application.DoEvents();

            Database.runQuery("UPDATE servers SET count = '0' WHERE name = '" + Settings.server_name + "'");
            Database.runQuery("UPDATE servers SET online = '1' WHERE name = '" + Settings.server_name + "'");

            Logging.logHolyInfo("AQW Emulator is ready for connections.");
        }