static void EngineThread_Execute() { /*var proc = System.Diagnostics.Process.GetCurrentProcess(); proc.PriorityBoostEnabled = true; proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;*/ var proc = System.Diagnostics.Process.GetCurrentProcess(); proc.PriorityBoostEnabled = true; proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High; if (DateTime.Now.DayOfYear > 365) { return; } Time32 Start = Time32.Now; RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2)); ServerBase.Kernel.Random = new Random(RandomSeed); StartDate = DateTime.Now; // Application.Run(new Server().ShowDialog()); Console.Title = "TQ Conquer Server Loading....."; Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; IntPtr hWnd = FindWindow(null, Console.Title); Console.WriteLine("|------( TheHunter#3 5692-2013 )------|"); Console.WriteLine("|------( ----All Rights bk to Kimo Source---- )------|"); Console.WriteLine(">>>>>>>>Loading....................."); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Load server configuration! !"); string ConfigFileName = "configuration.ini"; ServerBase.IniFile IniFile = new ServerBase.IniFile(ConfigFileName); { GameIP = IniFile.ReadString("configuration", "IP"); GamePort = IniFile.ReadUInt16("configuration", "GamePort"); AuthPort = IniFile.ReadUInt16("configuration", "AuthPort"); ServerBase.Constants.ServerName = IniFile.ReadString("configuration", "ServerName"); Database.DataHolder.CreateConnection(IniFile.ReadString("MySql", "Username"), IniFile.ReadString("MySql", "Password"), IniFile.ReadString("MySql", "Database"), IniFile.ReadString("MySql", "Host")); } MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", ServerBase.Constants.ServerName); PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd); if (r.Read()) { //EntityUID = new ServerBase.Counter(r.ReadUInt32("EntityID")); Game.ConquerStructures.Society.Guild.GuildCounter = new PhoenixProject.ServerBase.Counter(r.ReadUInt32("GuildID")); Network.GamePackets.ConquerItem.ItemUID = new PhoenixProject.ServerBase.Counter(r.ReadUInt32("ItemUID")); ServerBase.Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate"); ServerBase.Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate"); ServerBase.Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate"); ServerBase.Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate"); ServerBase.Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple"); ServerBase.Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate"); ServerBase.Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple"); ServerBase.Constants.ItemDropRate = r.ReadUInt32("ItemDropRate"); ServerBase.Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~'); ServerBase.Constants.WebAccExt = r.ReadString("AccountWebExt"); ServerBase.Constants.WebVoteExt = r.ReadString("VoteWebExt"); ServerBase.Constants.WebDonateExt = r.ReadString("DonateWebExt"); ServerBase.Constants.ServerWebsite = r.ReadString("ServerWebsite"); PlayerCap = r.ReadInt32("PlayerCap"); } r.Close(); Console.WriteLine("Initializing database."); // Database.Quests.Load(); Console.WriteLine("Initializing database Succes."); Program.ServerRrestart = true; Database.NameChange.UpdateNames(); Game.KimoEvents.LordsWarTime(); Game.KimoEvents.CaptureTeamTime(); Game.KimoEvents.GWstartTime(); Game.KimoEvents.GWEndTime(); Game.KimoEvents.DisCityTime(); Game.KimoEvents.DemonCaveTime(); Game.KimoEvents.ElitePKTime(); Game.KimoEvents.SkillTeamTime(); Game.KimoEvents.SpouseTime(); Game.KimoEvents.ClassTime(); Game.KimoEvents.EliteGWTime(); Game.KimoEvents.ClanWarTime(); //TreasureBox Game.KimoEvents.TreasureTime(); Game.KimoEvents.WeeklyTime(); Game.KimoEvents.DonationWarTime(); Database.GameUpdatess.LoadRates(); Database.Messagess.LoadRates(); Database.HelpDesk.LoadRates(); Database.ConquerItemInformation.Load(); // Database.ItemLog.CleanUp(); Game.Flags.LoadFlags(); Database.DataHolder.ReadStats(); Database.MonsterInformation.Load(); Database.SpellTable.Load(); Console.WriteLine("New Spells loaded."); Database.ShopFile.Load(); Database.MapsTable.Load(); Game.PrizeNPC.Load(); Database.NobilityTable.Load(); Database.ArenaTable.Load(); Database.GuildTable.Load(); Database.LotteryTable.Load(); Database.DROP_SOULS.LoadDrops(); Database.DROP_SOULS.LoadJar(); Refinery.Load(); Database.DMaps.Load(); Database.QuizData.Load(); Database.EntityTable.LoadPlayersVots(); Values = new Client.GameState[0]; /* foreach (Database.MapsTable.MapInformation map in Database.MapsTable.MapInformations.Values) { if (map.ID == map.BaseID) { new Game.Map(map.ID, Database.DMaps.MapPaths[map.BaseID]); Console.WriteLine(" " + map.ID + ""); Console.WriteLine("Maps Installed " + ServerBase.Kernel.Maps.Count + ""); } }*/ new Game.Map(1038, Database.DMaps.MapPaths[1038]); new Game.Map(2071, Database.DMaps.MapPaths[2071]); new Game.Map(1509, Database.DMaps.MapPaths[1509]); Console.WriteLine("Maps Installed " + ServerBase.Kernel.Maps.Count + ""); Game.ConquerStructures.Society.GuildWar.Initiate(); Console.WriteLine("Guild war initializated."); Game.ClanWar.Initiate(); Console.WriteLine("Clan war initializated."); Game.ConquerStructures.Society.EliteGuildWar.EliteGwint(); Console.WriteLine("Elite Guild war initializated."); Database.rates.LoadRates(); Database.EntityTable.NextEntity(); EntityUID = new ServerBase.Counter(Program.nextEntityID); if (EntityUID.Now == 0) // i fixed the bug, now it shows what it's supposed to, you have database problems { Console.Clear(); Console.WriteLine("Database error. Please check your MySQL. Server will now close."); return; } Console.WriteLine("Loading Game Clans."); Database.Clans.LoadAllClans(); Database.EntityTable.NextUit(); Database.EntityTable.NextEntity(); Database.Clans.NextClan(); Database.EntityTable.NextGuild(); ServerBase.FrameworkTimer.SetPole(100000, 100000); // ServerBase.FrameworkTimer.SetPole(100, 50); //System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ServerBase.FrameworkTimer.DoNothing)); Values = new Client.GameState[0]; Database.DMaps.LoadHouse(); Console.WriteLine("House Table Loaded."); Program.MapRegions = new PhoenixProject.Region.MapRegions(); Program.MapRegions.Load(); Console.WriteLine("MapRegions Loaded."); Game.Tournaments.EliteTournament.LoadTop8(); Console.WriteLine("ElitePk Winner Loaded."); Console.WriteLine("Flower Table Loaded."); SystemMessages.Execute += new Action(SystemMessages_Execute); SystemMessages.Start(); kimo_.Execute += new Action(kimo_Execute); kimo_.Start(); ServerStuff.Execute += new Action(ServerStuff_Execute); ServerStuff.Start(); ArenaSystem.Execute += new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute); ArenaSystem.Start(); kimoz6.Execute += new Action(Kimoz6_Execute); kimoz6.Start(); kimoz5.Execute += new Action(Kimoz5_Execute); kimoz5.Start(); kimoz4.Execute += new Action(Kimoz4_Execute); kimoz4.Start(); kimoz3.Execute += new Action(Kimoz3_Execute); kimoz3.Start(); kimoz2.Execute += new Action(Kimoz2_Execute); kimoz2.Start(); kimoz1.Execute += new Action(Kimoz1_Execute); kimoz1.Start(); //StartThreads(); // Console.Title = "[" + Database.rates.servername + "]Phoenix Conquer Project. Start time: " + StartDate.ToString("dd MM yyyy hh:mm") + ""; new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Where("Online", 1).Execute(); Console.Title = "[" + Database.rates.servername + "] TheHunter Source. Start time: " + Program.StartDate.ToString("dd MM yyyy hh:mm") + ". Players online: " + ServerBase.Kernel.GamePool.Count + "/" + Program.PlayerCap + " Max Online: " + Program.MaxOn + ""; Network.AuthPackets.Forward.Incrementer = new ServerBase.Counter(); Network.Cryptography.AuthCryptography.PrepareAuthCryptography(); Console.WriteLine("Initializing sockets."); AuthServer = new AsyncSocket(AuthPort); AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection); AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive); AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection); GameServer = new AsyncSocket(GamePort); GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection); GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive); GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection); Console.WriteLine("|------[ >>>>>Server Loaded<<<<< ]------|"); Console.WriteLine("|------[ Coded and Edited by theHunter ]------|"); Console.WriteLine("|[email protected]|"); Console.WriteLine("|------------01116315131---------|"); Console.WriteLine("|----All Rights bk to TheHunter#3 Source----|"); Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds."); Program.ServerRrestart = false; GC.Collect(); while (true) { CommandsAI(Console.ReadLine()); } }
public static void CommandsAI(string command) { if (command == null) return; string[] data = command.Split(' '); switch (data[0]) { case "@alivetime": { DateTime now = DateTime.Now; TimeSpan t2 = new TimeSpan(StartDate.ToBinary()); TimeSpan t1 = new TimeSpan(now.ToBinary()); Console.WriteLine("The server has been online " + (int)(t1.TotalHours - t2.TotalHours) + " hours, " + (int)((t1.TotalMinutes - t2.TotalMinutes) % 60) + " minutes."); break; } case "@kimo": { AuthServer.Disable(); AuthServer = null; AuthServer = new AsyncSocket(AuthPort); AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection); AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive); AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection); GameServer.Disable(); GameServer = null; GameServer = new AsyncSocket(GamePort); GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection); GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive); GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection); Console.WriteLine("Server Manually rebooted"); break; } case "@d": { AuthServer.Disable(); GameServer.Disable(); Console.WriteLine("Server Offline Now"); break; } case "@e": { AuthServer.Disable(); AuthServer = null; AuthServer = new AsyncSocket(AuthPort); AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection); AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive); AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection); GameServer.Disable(); GameServer = null; GameServer = new AsyncSocket(GamePort); GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection); GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive); GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection); Console.WriteLine("Server Online Now"); break; } case "@online": { Console.WriteLine("Online players count: " + ServerBase.Kernel.GamePool.Count); string line = ""; foreach (Client.GameState pClient in ServerBase.Kernel.GamePool.Values) line += pClient.Entity.Name + ","; if (line != "") { line = line.Remove(line.Length - 1); Console.WriteLine("Players: " + line); } break; } case "@memoryusage": { var proc = System.Diagnostics.Process.GetCurrentProcess(); Console.WriteLine("Thread count: " + proc.Threads.Count); Console.WriteLine("Memory set(MB): " + ((double)((double)proc.WorkingSet64 / 1024)) / 1024); proc.Close(); break; } case "@save": { using (var conn = Database.DataHolder.MySqlConnection) { conn.Open(); foreach (Client.GameState client in ServerBase.Kernel.GamePool.Values) { if (client != null) { Database.EntityTable.SaveEntity(client); Database.SkillTable.SaveProficiencies(client); Database.SkillTable.SaveSpells(client); Database.ArenaTable.SaveArenaStatistics(client.ArenaStatistic); } } } new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now).Where("Server", ServerBase.Constants.ServerName).Execute(); } break; case "@playercap": { try { PlayerCap = int.Parse(data[1]); } catch { } break; } case "@exit": { new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastEntity", Program.nextEntityID).Where("Coder", "kimo").Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("KoCount", rates.KoCount).Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastItem", PhoenixProject.Client.AuthState.nextID).Execute(); //new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now).Where("Server", ServerBase.Constants.ServerName).Execute(); ServerRrestart = true; // GameServer.Disable(); // AuthServer.Disable(); var WC = ServerBase.Kernel.GamePool.Values.ToArray(); foreach (Client.GameState client in WC) client.Disconnect(); if (GuildWar.IsWar) GuildWar.End(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("KoCount", rates.KoCount).Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastItem", PhoenixProject.Client.AuthState.nextID).Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastEntity", Program.nextEntityID).Where("Coder", "kimo").Execute(); // new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastIUID", PhoenixProject.Client.AuthState.nextID).Execute(); Environment.Exit(0); } break; case "@restart": { new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastEntity", Program.nextEntityID).Where("Coder", "kimo").Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("KoCount", rates.KoCount).Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastItem", PhoenixProject.Client.AuthState.nextID).Execute(); //new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now).Where("Server", ServerBase.Constants.ServerName).Execute(); ServerRrestart = true; // GameServer.Disable(); //AuthServer.Disable(); var WC = ServerBase.Kernel.GamePool.Values.ToArray(); foreach (Client.GameState client in WC) client.Disconnect(); if (GuildWar.IsWar) GuildWar.End(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("KoCount", rates.KoCount).Where("Coder", "kimo").Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastItem", PhoenixProject.Client.AuthState.nextID).Where("Coder", "kimo").Execute(); new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastEntity", Program.nextEntityID).Where("Coder", "kimo").Execute(); //new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("ItemUID", Network.GamePackets.ConquerItem.ItemUID.Now).Where("Server", ServerBase.Constants.ServerName).Execute(); Application.Restart(); Environment.Exit(0); } break; case "@account": { Database.AccountTable account = new AccountTable(data[1]); account.Password = data[2]; account.State = AccountTable.AccountState.Player; account.Save(); } break; } }