public static void Main(string[] args) { //LicenseFile lf = new LicenseFile(System.IO.File.ReadAllText("essential.license")); CustomCultureInfo.SetupCustomCultureInfo(); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.smethod_0); Program.delegate0_0 = (Program.EventHandler)Delegate.Combine(Program.delegate0_0, new Program.EventHandler(Program.smethod_1)); Program.SetConsoleCtrlHandler(Program.delegate0_0, true); try { Essential @class = new Essential(); @class.Initialize(); IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle; SetWindowPos(hWnd, new IntPtr(HWND_TOPMOST), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); Program.bool_0 = true; DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND); /* Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\r\n~~~ IF YOU WANT CLOSE EMULATOR PLEASE PRESS ESCAPE (Esc) BUTTON ~~~\r\n"); Console.ForegroundColor = ConsoleColor.Gray;*/ } catch (Exception ex) { Console.Write(ex.ToString()); } while (true) { ConsoleKeyInfo = Console.ReadKey(); if (ConsoleKeyInfo.Key == ConsoleKey.Escape) smethod_1(CtrlType.CTRL_CLOSE_EVENT); } }
public static void UpdateGroup(DatabaseClient class6_0, int int_0) { GroupsManager @class = Groups.GetGroupById(int_0); if (@class != null) { DataRow Row = class6_0.ReadDataRow("SELECT * FROM groups WHERE Id = " + int_0 + " LIMIT 1"); @class.Name = (string)Row["name"]; @class.Badge = (string)Row["badge"]; @class.RoomId = (uint)Row["roomid"]; @class.Description = (string)Row["desc"]; @class.Locked = (string)Row["locked"]; @class.ColorOne = (string)Row["color_one"]; @class.ColorTwo = (string)Row["color_two"]; @class.Created = Essential.TimestampToDate(double.Parse((string)Row["created"])).ToShortDateString(); @class.Members.Clear(); DataTable dataTable = class6_0.ReadDataTable("SELECT userid FROM group_memberships WHERE groupid = " + int_0 + ";"); foreach (DataRow dataRow2 in dataTable.Rows) { @class.JoinGroup((int)dataRow2["userid"]); } } }
public static void RemoveGroup(GroupsManager guild) { using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("DELETE FROM groups WHERE id=" + guild.Id); dbClient.ExecuteQuery("DELETE FROM group_memberships WHERE groupid=" + guild.Id); dbClient.ExecuteQuery("DELETE FROM group_requests WHERE groupid=" + guild.Id); dbClient.ExecuteQuery("UPDATE user_stats SET groupid=0 WHERE groupid=" + guild.Id); //dbClient.ExecuteQuery("UPDATE items SET guild_data='0;0;0' WHERE guild_data LIKE '" + guild.Id + ";%'"); foreach (GameClient gc in Essential.GetGame().GetClientManager().GetClients()) { if (gc != null && gc.GetHabbo() != null && gc.GetHabbo().InGuild(guild.Id)) { if (gc.GetHabbo().FavouriteGroup == guild.Id) { gc.GetHabbo().FavouriteGroup = 0; } gc.GetHabbo().RefreshGuilds(); } } Groups.GroupsManager.Remove(guild.Id); } }
internal static void InitGroups() { BaseBadges = new List <GroupsPartsData>(); SymbolBadges = new List <GroupsPartsData>(); ColorBadges1 = new List <GroupsPartsData>(); ColorBadges2 = new List <GroupsPartsData>(); ColorBadges3 = new List <GroupsPartsData>(); using (DatabaseClient adapter = Essential.GetDatabase().GetClient()) { DataTable table = adapter.ReadDataTable("SELECT * FROM groups_elements"); foreach (DataRow row in table.Rows) { GroupsPartsData data; if (row["Type"].ToString() == "Base") { data = new GroupsPartsData { Id = (int)row["Id"], ExtraData1 = (string)row["ExtraData1"], ExtraData2 = (string)row["ExtraData2"] }; BaseBadges.Add(data); } else if (row["ExtraData1"].ToString().StartsWith("symbol_")) { data = new GroupsPartsData { Id = (int)row["Id"], ExtraData1 = (string)row["ExtraData1"], ExtraData2 = (string)row["ExtraData2"] }; SymbolBadges.Add(data); } else if (row["Type"].ToString() == "Color1") { data = new GroupsPartsData { Id = (int)row["Id"], ExtraData1 = (string)row["ExtraData1"] }; ColorBadges1.Add(data); } else if (row["Type"].ToString() == "Color2") { data = new GroupsPartsData { Id = (int)row["Id"], ExtraData1 = (string)row["ExtraData1"] }; ColorBadges2.Add(data); } else if (row["Type"].ToString() == "Color3") { data = new GroupsPartsData { Id = (int)row["Id"], ExtraData1 = (string)row["ExtraData1"] }; ColorBadges3.Add(data); } } } }
internal static void Destroy(string string_8, bool ExitWhenDone, bool waitExit = false) { Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND); try { Internal_Game.StopGameLoop(); } catch { } try { if (Essential.GetPacketManager() != null) { Essential.GetPacketManager().Clear(); } } catch { } if (string_8 != "") { if (Essential.bool_1) { return; } Logging.Disable(); Essential.smethod_17("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity."); Essential.bool_1 = true; Console.WriteLine("Server shutting down..."); try { Essential.Internal_Game.GetRoomManager().method_4(); } catch { } try { Essential.GetSocketsManager().method_3().method_1(); //Essential.smethod_14().Destroy(); Essential.GetGame().GetClientManager().CloseAll(); } catch { } try { Console.WriteLine("Destroying database manager."); MySqlConnection.ClearAllPools(); Essential.DatabaseManager = null; } catch { } Console.WriteLine("System disposed, goodbye!"); } else { Logging.Disable(); Essential.bool_1 = true; try { if (Essential.Internal_Game != null && Essential.Internal_Game.GetRoomManager() != null) { Essential.Internal_Game.GetRoomManager().UnloadAllRooms(); Essential.Internal_Game.GetRoomManager().method_4(); } } catch { } try { if (Essential.GetSocketsManager() != null) { Essential.GetSocketsManager().method_3().method_1(); //Essential.smethod_14().Destroy(); Essential.GetGame().GetClientManager().CloseAll(); } } catch { } if (SocketsManager != null) { //Essential.ConnectionManage.method_7(); } if (Essential.Internal_Game != null) { Essential.Internal_Game.ContinueLoading(); } Console.WriteLine(string_8); } if (ExitWhenDone) { if (waitExit) { Console.WriteLine("Press any key to exit.."); Console.ReadKey(); } Environment.Exit(0); } }
internal static void Close() { Essential.Destroy("", true); }
public static void InitWebsocketManager() { webSocketServerManager = new WebSocketServerManager(Essential.GetConfig().data["websocket.url"]); }
public void Initialize() { Essential.consoleWriter = new ConsoleWriter(Console.Out); Console.SetOut(Essential.consoleWriter); try { Console.WindowWidth = 130; Console.WindowHeight = 36; } catch { } Essential.ServerStarted = DateTime.Now; Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine(@" ______ _ _ _ "); Console.WriteLine(@" | ____| | | (_) | |"); Console.WriteLine(@" | |__ ___ ___ ___ _ __ | |_ _ __ _| |"); Console.WriteLine(@" | __| / __/ __|/ _ \ '_ \| __| |/ _` | |"); Console.WriteLine(@" | |____\__ \__ \ __/ | | | |_| | (_| | |"); Console.WriteLine(@" |______|___/___/\___|_| |_|\__|_|\__,_|_|"); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" Essential Emulator Build " + Build + " by " + Creator); Console.WriteLine(); Console.WriteLine(" Credits to: Meth0d (Uber), Sojobo (Phoenix), Juniori (GTE) & Rootkit (Essential)"); Console.WriteLine(); Console.ResetColor(); try { Essential.Configuration = new ConfigurationData("config.conf"); DateTime now = DateTime.Now; try { Essential.SWFDirectory = Essential.GetConfig().data["web.api.furni.hof_furni"]; } catch { } if (!Directory.Exists("API")) { Directory.CreateDirectory("API"); } DatabaseServer dbServer = new DatabaseServer(Essential.GetConfig().data["db.hostname"], uint.Parse(Essential.GetConfig().data["db.port"]), Essential.GetConfig().data["db.username"], Essential.GetConfig().data["db.password"]); Database database = new Database(Essential.GetConfig().data["db.name"], uint.Parse(Essential.GetConfig().data["db.pool.minsize"]), uint.Parse(Essential.GetConfig().data["db.pool.maxsize"])); Essential.DatabaseManager = new DatabaseManager(dbServer, database); GroupsPartsData.InitGroups(); try { using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("SET @@global.sql_mode= '';"); dbClient.ExecuteQuery("UPDATE users SET online = '0'"); dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0'"); } Essential.Internal_Game.ContinueLoading(); } catch { } Essential.Internal_Game = new Game(int.Parse(Essential.GetConfig().data["game.tcp.conlimit"])); Essential.PacketManager = new PacketManager(); Essential.PacketManager.Load(); Essential.mhandler = new MobileHandler(); Essential.mhandler.Load(); Console.WriteLine(Essential.PacketManager.Count + " Packets loaded!"); Essential.antiAdSystem = new AntiAd(); Essential.MusListener = new MusListener(Essential.GetConfig().data["mus.tcp.bindip"], int.Parse(Essential.GetConfig().data["mus.tcp.port"]), Essential.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20); Essential.SocketsManager = new SocketsManager(Essential.GetConfig().data["game.tcp.bindip"], int.Parse(Essential.GetConfig().data["game.tcp.port"]), int.Parse(Essential.GetConfig().data["game.tcp.conlimit"])); //ConnectionManage = new ConnectionHandeling(Essential.GetConfig().data["game.tcp.port"], int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]), int.Parse(Essential.GetConfig().data["game.tcp.conlimit"]), true); Essential.HeadImagerURL = Essential.GetConfig().data["eventstream.imager.url"]; using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("UPDATE server_status SET bannerdata='" + EssentialEnvironment.globalCrypto.Prime + ":" + EssentialEnvironment.globalCrypto.Generator + "';"); } Essential.SocketsManager.method_3().method_0(); webSocketServerManager = new WebSocketServerManager(Essential.GetConfig().data["websocket.url"]); Console.WriteLine("Server started at " + Essential.GetConfig().data["websocket.url"]); webManager = new WebManager(); TimeSpan timeSpan = DateTime.Now - now; Logging.WriteLine(string.Concat(new object[] { "Server -> READY! (", timeSpan.Seconds, " s, ", timeSpan.Milliseconds, " ms)" })); using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { dbClient.ExecuteQuery("UPDATE server_status SET server_started='" + Convert.ToInt32(GetUnixTimestamp()) + "'"); } Console.Beep(); } catch (KeyNotFoundException KeyNotFoundException) { Logging.WriteLine("Failed to boot, key not found: " + KeyNotFoundException); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); Essential.Destroy(); } catch (InvalidOperationException ex) { Logging.WriteLine("Failed to initialize EssentialEmulator: " + ex.Message); Logging.WriteLine("Press any key to shut down ..."); Console.ReadKey(true); Essential.Destroy(); } }