Beispiel #1
0
        public static void Start()
        {
            serverConfig = ConfigElement.GetAll(typeof(ServerConfig));
            levelConfig  = ConfigElement.GetAll(typeof(LevelConfig));
            zoneConfig   = ConfigElement.GetAll(typeof(ZoneConfig));

            #pragma warning disable 0618
            Player.players = PlayerInfo.Online.list;
            Server.levels  = LevelInfo.Loaded.list;
            #pragma warning restore 0618

            StartTime    = DateTime.UtcNow;
            shuttingDown = false;
            Logger.Log(LogType.SystemActivity, "Starting Server");
            ServicePointManager.Expect100Continue = false;

            CheckFile("MySql.Data.dll");
            CheckFile("sqlite3_x32.dll");
            CheckFile("sqlite3_x64.dll");
            CheckFile("LibNoise.dll");

            EnsureFilesExist();
            MoveSqliteDll();
            MoveOutdatedFiles();

            LoadAllSettings();
            SrvProperties.GenerateSalt();

            InitDatabase();
            Economy.LoadDatabase();

            Background.QueueOnce(UpgradeTasks.CombineEnvFiles);
            Background.QueueOnce(LoadMainLevel);
            Plugin.LoadAll();
            Background.QueueOnce(LoadAutoloadMaps);
            Background.QueueOnce(UpgradeTasks.MovePreviousLevelFiles);
            Background.QueueOnce(UpgradeTasks.UpgradeOldTempranks);
            Background.QueueOnce(UpgradeTasks.UpgradeDBTimeSpent);
            Background.QueueOnce(InitPlayerLists);
            Background.QueueOnce(UpgradeTasks.UpgradeBots);

            Background.QueueOnce(SetupSocket);
            Background.QueueOnce(InitTimers);
            Background.QueueOnce(InitRest);
            Background.QueueOnce(InitHeartbeat);

            Devs.Clear();
            Mods.Clear();
            Background.QueueOnce(InitTasks.UpdateStaffList);

            ServerTasks.QueueTasks();
            Background.QueueRepeat(ThreadSafeCache.DBCache.CleanupTask,
                                   null, TimeSpan.FromMinutes(5));
        }
Beispiel #2
0
 void UpdateStaffListTask()
 {
     try {
         using (WebClient web = new WebClient()) {
             string[] result = web.DownloadString(staffUrl).Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
             foreach (string line in result)
             {
                 string        type      = line.Split(':')[0].ToLower();
                 List <string> staffList = type.Equals("devs") ? Devs : type.Equals("mods") ? Mods : null;
                 foreach (string name in line.Split(':')[1].Split())
                 {
                     staffList.Add(name);
                 }
             }
         }
     } catch (Exception e) {
         ErrorLog(e);
         s.Log("Failed to update MCGalaxy staff list.");
         Devs.Clear();
         Mods.Clear();
     }
 }
Beispiel #3
0
        public void Start()
        {
            serverConfig = ConfigElement.GetAll(typeof(Server), typeof(ZombieGameProps));
            levelConfig  = ConfigElement.GetAll(typeof(Level));

            #pragma warning disable 0618
            Player.players       = PlayerInfo.Online.list;
            PlayerInfo.players   = PlayerInfo.Online.list;
            Server.levels        = LevelInfo.Loaded.list;
            PlayerBot.playerbots = PlayerBot.Bots.list;
            #pragma warning restore 0618

            StartTime      = DateTime.UtcNow;
            StartTimeLocal = StartTime.ToLocalTime();
            shuttingDown   = false;
            Log("Starting Server");
            try {
                if (File.Exists("Restarter.exe"))
                {
                    File.Delete("Restarter.exe");
                }
            } catch { }
            try {
                if (File.Exists("Restarter.pdb"))
                {
                    File.Delete("Restarter.pdb");
                }
            } catch { }

            CheckFile("MySql.Data.dll");
            CheckFile("System.Data.SQLite.dll");
            CheckFile("sqlite3.dll");
            CheckFile("Newtonsoft.Json.dll");
            CheckFile("LibNoise.dll");

            EnsureFilesExist();
            MoveOutdatedFiles();

            lava      = new LavaSurvival();
            zombie    = new ZombieGame();
            Countdown = new CountdownGame();
            LoadAllSettings();

            InitDatabase();
            Economy.LoadDatabase();
            Server.zombie.CheckTableExists();

            Level[] loaded = LevelInfo.Loaded.Items;
            foreach (Level l in loaded)
            {
                l.Unload();
            }

            Background.QueueOnce(UpgradeTasks.CombineEnvFiles);
            Background.QueueOnce(LoadMainLevel);
            Plugin.Load();
            Background.QueueOnce(UpgradeTasks.UpgradeOldBlacklist);
            Background.QueueOnce(LoadPlayerLists);
            Background.QueueOnce(LoadAutoloadCommands);
            Background.QueueOnce(UpgradeTasks.MovePreviousLevelFiles);
            Background.QueueOnce(UpgradeTasks.UpgradeOldLockdown);

            Background.QueueOnce(SetupSocket);
            Background.QueueOnce(InitTimers);
            Background.QueueOnce(InitRest);
            Background.QueueOnce(InitHeartbeat);

            Devs.Clear();
            Mods.Clear();
            Background.QueueOnce(InitTasks.UpdateStaffList);

            MainScheduler.QueueRepeat(ServerTasks.TemprankExpiry,
                                      null, TimeSpan.FromMinutes(1));
            Background.QueueRepeat(ServerTasks.AutoSave,
                                   1, TimeSpan.FromSeconds(Server.backupInterval));
            Background.QueueRepeat(ServerTasks.BlockUpdates,
                                   null, TimeSpan.FromSeconds(Server.blockInterval));
            Background.QueueRepeat(ThreadSafeCache.DBCache.CleanupTask,
                                   null, TimeSpan.FromMinutes(5));
        }
Beispiel #4
0
 void UpdateStaffList()
 {
     Devs.Clear();
     Mods.Clear();
     ml.Queue(UpdateStaffListTask);
 }