private static void InitUCS() { if (!Directory.Exists("logs")) { Console.WriteLine("Folder \"logs/\" does not exist. Let me create one.."); Directory.CreateDirectory("logs"); } if (Convert.ToBoolean(Utils.parseConfigString("UCSList"))) { Ucslist.Start(); } new ResourcesManager(); new ObjectManager(); new Gateway().Start(); if (Convert.ToBoolean(Utils.parseConfigString("apiManager"))) { new ApiManager(); } if (Convert.ToBoolean(Utils.parseConfigString("apiManagerPro"))) { if (ConfigurationManager.AppSettings["ApiKey"] == "ucs") { var ch = Utils.GenerateApi(); ConfigurationManager.AppSettings.Set("ApiKey", ch); Console.WriteLine("Your Random API key : {0}", ch); } var ws = new ApiManagerPro(ApiManagerPro.SendResponse, "http://+:" + Utils.ParseConfigInt("proDebugPort") + "/" + Utils.parseConfigString("ApiKey") + "/"); Console.WriteLine("Your API key : {0}", Utils.parseConfigString("ApiKey")); ws.Run(); } Debugger.SetLogLevel(Utils.ParseConfigInt("loggingLevel")); Logger.SetLogLevel(Utils.ParseConfigInt("loggingLevel")); InitProgramThreads(); if (Utils.ParseConfigInt("loggingLevel") >= 5) { Debugger.WriteLine("\t", null, 5); Debugger.WriteLine("Played ID's:", null, 5, ConsoleColor.Cyan); ResourcesManager.GetAllPlayerIds() .ForEach(id => Debugger.WriteLine("\t" + id, null, 5, ConsoleColor.Cyan)); Debugger.WriteLine("\t", null, 5); } Console.WriteLine("Server started on port " + Port + ". Let's play Clash of Clans!"); if (Convert.ToBoolean(Utils.parseConfigString("consoleCommand"))) { new Menu(); } else { Application.Run(new UCSManager()); } }
private void ServerStartBtn_Click(object sender, EventArgs e) { tabControl1.SelectedTab = tabPage3; ConsoleWrite("Ultrapowa Clash Server "); ConsoleWrite("Loading Config File..."); ConsoleWrite("\t Set Starting Gems to " + int.Parse(ConfigurationManager.AppSettings["StartingGems"])); ConsoleWrite("\t Set Starting Gold to " + int.Parse(ConfigurationManager.AppSettings["StartingGold"])); ConsoleWrite("\t Set Starting Elixir to " + int.Parse(ConfigurationManager.AppSettings["StartingElixir"])); ConsoleWrite("\t Set Starting Dark Elixir to " + int.Parse(ConfigurationManager.AppSettings["StartingDarkElixir"])); ConsoleWrite("\t Set Starting Trophies to " + int.Parse(ConfigurationManager.AppSettings["StartingTrophies"])); ConsoleWrite("\t Set Starting Shield Time to " + int.Parse(ConfigurationManager.AppSettings["StartingShieldTime"])); ConsoleWrite("\t Set Client Version to " + double.Parse(ConfigurationManager.AppSettings["clientVersion"])); ConsoleWrite("\t Enable Custom Patch : " + bool.Parse(ConfigurationManager.AppSettings["useCustomPatch"])); ConsoleWrite("\t Patching Server : " + ConfigurationManager.AppSettings["patchingServer"]); ConsoleWrite("\t Enable Maintenance Mode : " + bool.Parse(ConfigurationManager.AppSettings["maintenanceMode"])); ConsoleWrite("\t Debugging Host : http://localhost:" + ConfigurationManager.AppSettings["debugPort"] + "/"); ConsoleWrite("\t Set Logging Level to " + int.Parse(ConfigurationManager.AppSettings["loggingLevel"])); ConsoleWrite("\t Set database Connection name : " + ConfigurationManager.AppSettings["databaseConnectionName"]); var rm = new ResourcesManager(); var pm = new ObjectManager(); new Gateway().Start(); new ApiManager(); InitProgramThreads(); StatusLabel.Text = "Loading Object Manager"; StatusLabel.Text = "Loading Message Manager"; StatusLabel.Text = "Loading Packet Manager"; StatusLabel.Text = "Loading Gateway"; StatusLabel.Text = "Starting API Manager"; Debugger.SetLogLevel(int.Parse(ConfigurationManager.AppSettings["loggingLevel"])); Logger.SetLogLevel(int.Parse(ConfigurationManager.AppSettings["loggingLevel"])); ConsoleWrite("Server Started."); ServerStartBtn.Enabled = false; timer1.Enabled = true; timer2.Enabled = true; StatusLabel.Text = "Status : Started"; iInfoLabel.Text = "Auto Updating Information and More After 30Sec"; SkipRemInfoUpdateBtn.Visible = true; ServerIsStartedYN = 1; StartRMSystemBtn.Enabled = true; PlayersMailBoxBtn.Enabled = true; GlobalChatBtn.Enabled = true; LoadPlayerProfileBtn.Enabled = true; UpdateInfo(); }
private static void InitProgramThreads() { Debugger.WriteLine("\t", null, 5); Debugger.WriteLine("Server Thread's:", null, 5, ConsoleColor.Blue); var programThreads = new List <Thread>(); for (var i = 0; i < int.Parse(ConfigurationManager.AppSettings["programThreadCount"]); i++) { var pt = new ProgramThread(); programThreads.Add(new Thread(pt.Start)); programThreads[i].Start(); Debugger.WriteLine("\tServer Running On Thread " + i, null, 5, ConsoleColor.Blue); } Console.ResetColor(); }
public static void RestartProgram() { Debugger.WriteLine("Starting saving all player to database", null, 0, ConsoleColor.Cyan); ResourcesManager.GetOnlinePlayers().ForEach(DatabaseManager.Singelton.Save); Process.Start(@"tools\ucs-restart.bat"); }
public static void ExitProgram() { Debugger.WriteLine("Starting saving all player to database", null, 0, ConsoleColor.Cyan); ResourcesManager.GetOnlinePlayers().ForEach(DatabaseManager.Singelton.Save); Environment.Exit(1); }