Пример #1
0
 public static void smethod_16()
 {
     Logging.WriteLine("Destroying GoldTreeEmu environment...");
     if (GoldTree.GetGame() != null)
     {
         GoldTree.GetGame().ContinueLoading();
         GoldTree.Game = null;
     }
     if (GoldTree.smethod_14() != null)
     {
         Logging.WriteLine("Destroying connection manager.");
         GoldTree.smethod_14().method_3().method_2();
         GoldTree.smethod_14().method_0();
         GoldTree.ConnectionManage = null;
     }
     if (GoldTree.GetDatabase() != null)
     {
         try
         {
             Logging.WriteLine("Destroying database manager.");
             MySqlConnection.ClearAllPools();
             GoldTree.DatabaseManager = null;
         }
         catch
         {
         }
     }
     Logging.WriteLine("Uninitialized successfully. Closing.");
 }
Пример #2
0
        public static void Destroy()
        {
            Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
            Logging.WriteLine("Destroying GoldTreeEmu environment...");

            if (GoldTree.GetGame() != null)
            {
                GoldTree.GetGame().ContinueLoading();
                GoldTree.Internal_Game = null;
            }

            if (GoldTree.GetSocketsManager() != null)
            {
                Logging.WriteLine("Destroying connection manager.");
                GoldTree.GetSocketsManager().method_3().method_2();
                //GoldTree.smethod_14().Destroy();
                GoldTree.GetSocketsManager().method_0();
                GoldTree.SocketsManager = null;
            }

            if (GoldTree.GetDatabase() != null)
            {
                try
                {
                    Logging.WriteLine("Destroying database manager.");
                    MySqlConnection.ClearAllPools();
                    GoldTree.DatabaseManager = null;
                }
                catch
                {
                }
            }

            Logging.WriteLine("Uninitialized successfully. Closing.");
        }
Пример #3
0
 public Class114(string string_0, int int_2, int maxConnections, SocketsManager class113_1)
 {
     this.int_1 = Process.GetCurrentProcess().Id;
     this.socket_0 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(Essential.GetConfig().data["game.tcp.bindip"]), int_2);
     this.socket_0.Bind(localEP);
     this.socket_0.Listen(133337);
     this.asyncCallback_0 = new AsyncCallback(this.method_4);
     this.class113_0 = class113_1;
     AntiDDosSystem.SetupTcpAuthorization(20000);
     Logging.WriteLine("Listening for connections on port: " + int_2 + " | Max connections is: 133337");
 }
Пример #4
0
        public static void Destroy()
        {
            Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
            Console.BackgroundColor = ConsoleColor.Black;
            Logging.WriteLine("Destroying Unicorn environment...");

            if (HabboIM.GetGame() != null)
            {
                HabboIM.GetGame().ContinueLoading();
                HabboIM.Internal_Game = null;
            }

            if (HabboIM.GetSocketsManager() != null)
            {
                Logging.WriteLine("Destroying connection manager.");
                HabboIM.GetSocketsManager().method_3().method_2();
                //HabboIM.smethod_14().Destroy();
                HabboIM.GetSocketsManager().method_0();
                HabboIM.SocketsManager = null;
            }

            if (HabboIM.GetDatabase() != null)
            {
                try
                {
                    Logging.WriteLine("Destroying database manager.");
                    MySqlConnection.ClearAllPools();
                    HabboIM.DatabaseManager = null;
                }
                catch
                {
                }
            }

            Logging.WriteLine("Uninitialized successfully. Closing.");
        }
Пример #5
0
 public void method_2()
 {
     this.method_1();
     this.socket_0 = null;
     this.class113_0 = null;
 }
Пример #6
0
        public void Initialize()
        {
            Logging.WriteLine("█▀▀▀█ █ █ █  █ █    ▀  █▀▀▀ █  █ ▀▀█▀▀", ConsoleColor.Yellow);
            Logging.WriteLine("▀▀▀▄▄ █▀▄ █▄▄█ █   ▀█▀ █ ▀█ █▀▀█   █  ", ConsoleColor.Yellow);
            Logging.WriteLine("█▄▄▄█ ▀ ▀ ▄▄▄█ ▀▀▀ ▀▀▀ ▀▀▀▀ ▀  ▀   ▀  ", ConsoleColor.Yellow);
            Logging.WriteLine(Skylight.Version, ConsoleColor.Yellow);
            Logging.WriteBlank();

            Logging.WriteLine(Licence.WelcomeMessage, ConsoleColor.Green);
            Logging.WriteBlank();

            try
            {
                Skylight.ServerStarted     = Stopwatch.StartNew();
                Skylight.ConfigurationData = new ConfigurationData("config.conf");

                Logging.Write("Connecting to database... ", ConsoleColor.White);
                try
                {
                    DatabaseServer DatabaseServer = new DatabaseServer(Skylight.GetConfig()["db.hostname"], uint.Parse(Skylight.GetConfig()["db.port"]), Skylight.GetConfig()["db.username"], Skylight.GetConfig()["db.password"]);
                    Database       Database       = new Database(Skylight.GetConfig()["db.name"], uint.Parse(Skylight.GetConfig()["db.pool.minsize"]), uint.Parse(Skylight.GetConfig()["db.pool.maxsize"]));
                    Skylight.DatabaseManager = new DatabaseManager(DatabaseServer, Database);

                    using (DatabaseClient dbClient = Skylight.DatabaseManager.GetClient())
                    {
                        //WHAT AN LOVLY COMMAND WE HAVE OVER HERE! =D
                        dbClient.ExecuteQuery(@"DROP PROCEDURE IF EXISTS parse_activity_points;
CREATE PROCEDURE parse_activity_points(bound VARCHAR(255), bound2 VARCHAR(255))
  BEGIN
    DECLARE id INT DEFAULT 0;
    DECLARE value TEXT;
    DECLARE occurance INT DEFAULT 0;
    DECLARE i INT DEFAULT 0;
    DECLARE splitted_value TEXT;
    DECLARE splitted_value_2 TEXT;
    DECLARE splitted_value_3 TEXT;
    DECLARE done INT DEFAULT 0;
    DECLARE cur1 CURSOR FOR SELECT users.id, users.activity_points FROM users;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    DROP TEMPORARY TABLE IF EXISTS activity_points_parsed_data;
    CREATE TEMPORARY TABLE activity_points_parsed_data(`id` INT NOT NULL,`value` VARCHAR(255) NOT NULL,`value2` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`,`value`)) ENGINE=Memory;
    OPEN cur1;
      read_loop: LOOP
        FETCH cur1 INTO id, value;
        IF done THEN LEAVE read_loop;
        END IF;
        SET occurance = (SELECT LENGTH(value) - LENGTH(REPLACE(value, bound, '')) +1);
        SET i=1;
        WHILE i <= occurance DO
          SET splitted_value = (SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(value, bound, i), LENGTH(SUBSTRING_INDEX(value, bound, i - 1)) + 1), bound, ''));
					SET splitted_value_2 = (SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(splitted_value, bound2, 1), LENGTH(SUBSTRING_INDEX(splitted_value, bound2, 1 - 1)) + 1), bound2, ''));
					SET splitted_value_3 = (SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(splitted_value, bound2, 2), LENGTH(SUBSTRING_INDEX(splitted_value, bound2, 2 - 1)) + 1), bound2, ''));
                    IF splitted_value_3 = '' THEN SET splitted_value_3 = splitted_value_2, splitted_value_2 = '0'; END IF;
          INSERT INTO activity_points_parsed_data VALUES (id, splitted_value_2, splitted_value_3) ON DUPLICATE KEY UPDATE value2 = value2 + splitted_value_3;
          SET i = i + 1;
        END WHILE;
      END LOOP;
    CLOSE cur1;
  END;");
                    }
                }
                catch (MySqlException ex)
                {
                    Logging.WriteLine("failed!", ConsoleColor.Red);

                    Skylight.ExceptionShutdown(ex);
                    return;
                }
                Logging.WriteLine("completed!", ConsoleColor.Green);

                Skylight.LateQueryManager = new LateQueryManager();

                Skylight.PublicToken = new BigInteger(DiffieHellman.GenerateRandomHexString(15), 16).ToString();
                Skylight.HabboCrypto = new HabboCrypto(n, e, d);

                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.AddParamWithValue("bannerData", Skylight.HabboCrypto.Prime + ":" + Skylight.HabboCrypto.Generator);
                    dbClient.ExecuteQuery("UPDATE users SET online = '0'; UPDATE rooms SET users_now = '0'; UPDATE server_settings SET banner_data = @bannerData;");
                }

                Skylight.TargetRevision       = RevisionUtilies.StringToRevision(Skylight.GetConfig()["game.revision"]);
                Skylight.MultiRevisionSupport = TextUtilies.StringToBool(Skylight.GetConfig()["game.mrs.enabled"]);

                Skylight.PacketManager = BasicUtilies.GetRevisionPacketManager(Skylight.Revision); //needed for stuff
                Skylight.PacketManager.Initialize();

                Skylight.Game = new Game();
                Skylight.Game.Init();

                if (Skylight.GetConfig()["game.efpfr.enabled"] == "1")
                {
                    Skylight.ExternalFlashPolicyFileRequestPort = true;
                    Skylight.FlashPolicyFileRequestListener     = new FlashPolicyFileRequestListener(Skylight.GetConfig()["game.efpfr.bindip"], int.Parse(Skylight.GetConfig()["game.efpfr.port"]));
                    Skylight.FlashPolicyFileRequestListener.Start();
                }

                Skylight.SocketsManager = new SocketsManager(Skylight.GetConfig()["game.tcp.bindip"], int.Parse(Skylight.GetConfig()["game.tcp.port"]), int.Parse(Skylight.GetConfig()["game.tcp.conlimit"]));
                foreach (string key in Skylight.ConfigurationData.GetChildKeys("game.tcp.extra"))
                {
                    Skylight.SocketsManager.AddListener(new SocketsListener(Skylight.SocketsManager, Skylight.GetConfig()["game.tcp.extra." + key + ".bindip"], int.Parse(Skylight.GetConfig()["game.tcp.extra." + key + ".port"]), RevisionUtilies.StringToRevision(Skylight.GetConfig()["game.tcp.extra." + key + ".revision"]), RevisionUtilies.StringToCrypto(Skylight.GetConfig().TryGet("game.tcp.extra." + key + ".crypto"))));
                }
                Skylight.SocketsManager.Start();

                if (Skylight.GetConfig()["rcon.tcp.enabled"] == "1")
                {
                    Skylight.RCONListener = new RCONListener(Skylight.GetConfig()["rcon.tcp.bindip"], int.Parse(Skylight.GetConfig()["rcon.tcp.port"]), Skylight.GetConfig()["rcon.tcp.allowedips"]);
                    Skylight.RCONListener.Start();
                }

                if (Skylight.GetConfig()["mus.tcp.enabled"] == "1")
                {
                    Skylight.MUSListener = new MUSListener(Skylight.GetConfig()["mus.tcp.bindip"], int.Parse(Skylight.GetConfig()["mus.tcp.port"]));
                    Skylight.MUSListener.Start();
                }

                TimeSpan bootTime = Skylight.Uptime;
                Logging.WriteLine("READY! (" + bootTime.Seconds + " s, " + bootTime.Milliseconds + " ms)", ConsoleColor.Green);
            }
            catch (Exception ex)
            {
                Logging.WriteLine("FAILED TO BOOT! ", ConsoleColor.Red);

                Skylight.ExceptionShutdown(ex);
            }
        }
Пример #7
0
        public static void Destroy(bool close, bool takeBackup, bool backupCompress, bool restart)
        {
            if (Skylight.ServerShutdown)
            {
                return;
            }

            Skylight.ServerShutdown = true;

            try //we dont want shutdowns fails bcs of this
            {
                ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                message.Init(r63aOutgoing.SendNotifFromAdmin);
                message.AppendString("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity.");
                byte[] data = message.GetBytes();

                foreach (GameClient client in Skylight.GetGame().GetGameClientManager().GetClients())
                {
                    try //try send
                    {
                        if (client != null)
                        {
                            client.SendData(data);
                        }
                    }
                    catch //ignore error
                    {
                    }
                }
            }
            catch //nothing special really
            {
            }

            if (Skylight.ExternalFlashPolicyFileRequestPort)
            {
                Logging.Write("Disposing efpfr listener... ");
                if (Skylight.FlashPolicyFileRequestListener != null)
                {
                    Skylight.FlashPolicyFileRequestListener.Stop();
                }
                Skylight.FlashPolicyFileRequestListener = null;
                Logging.WriteLine("DONE!", ConsoleColor.Green);
            }

            Logging.Write("Disposing socket manager... ");
            if (Skylight.SocketsManager != null)
            {
                Skylight.SocketsManager.Stop();
            }
            Skylight.SocketsManager = null;
            Logging.WriteLine("DONE!", ConsoleColor.Green);

            Logging.Write("Disposing packet manager... ");
            if (Skylight.PacketManager != null) //release memory
            {
                Skylight.PacketManager.Clear();
            }
            Skylight.PacketManager = null;
            Logging.WriteLine("DONE!", ConsoleColor.Green);

            Logging.Write("Disposing RCON... ");
            if (Skylight.RCONListener != null)
            {
                Skylight.RCONListener.Stop();
            }
            Logging.WriteLine("DONE!", ConsoleColor.Green);

            Logging.Write("Disposing game... ");
            if (Skylight.Game != null)
            {
                Skylight.Game.Shutdown();
            }
            Skylight.Game = null;
            Logging.WriteLine("DONE!", ConsoleColor.Green);

            if (takeBackup)
            {
                Logging.WriteLine("Taking backup... ");
                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.TakeBackup(backupCompress);
                }
                Logging.WriteLine("DONE!", ConsoleColor.Green);
            }

            Logging.Write("Disposing database... ");
            if (Skylight.DatabaseManager != null)
            {
                MySqlConnection.ClearAllPools();
            }
            Skylight.DatabaseManager = null;
            Logging.WriteLine("DONE!", ConsoleColor.Green);

            Logging.WriteLine("");
            Logging.WriteLine("Server closed propriety!", ConsoleColor.Green);

            if (restart)
            {
                Process.Start(AppDomain.CurrentDomain.FriendlyName);
            }

            if (close)
            {
                Environment.Exit(0);
            }
        }
Пример #8
0
    void Start()
    {
        manager = GameObject.FindGameObjectWithTag ( "Manager" );
        startupManager = manager.GetComponent<StartupManager> ();
        socketsManager = manager.GetComponent<SocketsManager> ();
        onlineMusicBrowser = GameObject.FindGameObjectWithTag ( "OnlineMusicBrowser" ).GetComponent <OnlineMusicBrowser>();
        paneManager = manager.GetComponent <PaneManager> ();
        loadingImage = GameObject.FindGameObjectWithTag ( "LoadingImage" ).GetComponent<LoadingImage>();
        currentSlideshowImage = GameObject.FindGameObjectWithTag ( "SlideshowImage" ).GetComponent<GUITexture>();
        currentSong = GameObject.FindGameObjectWithTag ( "CurrentSong" ).GetComponent<GUIText>();

        musicViewerPosition.width = Screen.width;
        musicViewerPosition.height = Screen.height;

        bottomBarPosition = new Rect (( musicViewerPosition.width - 240 ) / 2 , musicViewerPosition.height - 18, 240, 54 );

        optionsWindowRect.x = musicViewerPosition.width/2 - optionsWindowRect.width/2;
        optionsWindowRect.y = musicViewerPosition.height/2 - optionsWindowRect.height/2;

        audioVisualizer = GameObject.FindGameObjectWithTag ("AudioVisualizer").GetComponent<AudioVisualizer> ();

        timemark = GameObject.FindGameObjectWithTag ( "Timemark" ).GetComponent<GUIText> ();
        GameObject.FindGameObjectWithTag ( "TimebarImage" ).guiTexture.pixelInset = new Rect ( -musicViewerPosition.width/2, musicViewerPosition.height/2 - 3, musicViewerPosition.width, 6 );

        LoadSettings ( false );

        centerStyle = new GUIStyle ();
        centerStyle.alignment = TextAnchor.MiddleCenter;

        labelStyle = new GUIStyle ();
        labelStyle.alignment = TextAnchor.MiddleCenter;
        labelStyle.wordWrap = true;

        folderStyle = new GUIStyle ();
        folderStyle.alignment = TextAnchor.MiddleLeft;
        folderStyle.border = new RectOffset ( 6, 6, 4, 4 );
        folderStyle.hover.background = guiSkin.button.hover.background;
        folderStyle.active.background = guiSkin.button.active.background;
        folderStyle.fontSize = 22;

        fileStyle = new GUIStyle ();
        fileStyle.alignment = TextAnchor.MiddleLeft;
        fileStyle.border = new RectOffset ( 6, 6, 6, 4 );
        fileStyle.padding = new RectOffset ( 6, 6, 3, 3 );
        fileStyle.margin = new RectOffset ( 4, 4, 4, 4 );
        fileStyle.hover.background = guiSkin.button.hover.background;
        fileStyle.active.background = guiSkin.button.active.background;
        fileStyle.fontSize = 22;

        fileBrowserFileStyle = new GUIStyle ();
        fileBrowserFileStyle.alignment = TextAnchor.MiddleLeft;

        currentSongStyle = new GUIStyle ();
        currentSongStyle.font = secretCode;
        currentSongStyle.fontSize = 31;

        songStyle = new GUIStyle ();
        songStyle.alignment = TextAnchor.MiddleLeft;
        songStyle.fontSize = 16;

        buttonStyle = new GUIStyle ();
        buttonStyle.fontSize = 22;
        buttonStyle.alignment = TextAnchor.MiddleCenter;
        buttonStyle.border = new RectOffset ( 6, 6, 6, 4 );
        buttonStyle.padding = new RectOffset ( 6, 6, 3, 3 );
        buttonStyle.margin = new RectOffset ( 4, 4, 4, 4 );
        buttonStyle.hover.background = guiSkin.button.hover.background;

        hideGUIStyle = new GUIStyle ();
        hideGUIStyle.normal.background = hideGUINormal;
        hideGUIStyle.hover.background = hideGUIHover;
        hideGUIStyle.onNormal.background = hideGUIOnNormal;
        hideGUIStyle.onHover.background = hideGUIOnHover;

        showVisualizerStyle = new GUIStyle ();
        showVisualizerStyle.normal.background = showAudioVisualizerNormal;
        showVisualizerStyle.hover.background = showAudioVisualizerHover;
        showVisualizerStyle.onNormal.background = showAudioVisualizerOnNormal;
        showVisualizerStyle.onHover.background = showAudioVisualizerOnHover;

        doubleSpeedStyle = new GUIStyle ();
        doubleSpeedStyle.normal.background = audioSpeedDoubleNormal;
        doubleSpeedStyle.hover.background = audioSpeedDoubleHover;
        doubleSpeedStyle.onNormal.background = audioSpeedNormalNormal;
        doubleSpeedStyle.onHover.background = audioSpeedNormalHover;

        halfSpeedStyle = new GUIStyle ();
        halfSpeedStyle.normal.background = audioSpeedHalfNormal;
        halfSpeedStyle.hover.background = audioSpeedHalfHover;
        halfSpeedStyle.onNormal.background = audioSpeedNormalNormal;
        halfSpeedStyle.onHover.background = audioSpeedNormalHover;

        echoStyle = new GUIStyle ();
        echoStyle.normal.background = echoNormal;
        echoStyle.hover.background = echoHover;
        echoStyle.onNormal.background = echoOnNormal;
        echoStyle.onHover.background = echoOnHover;

        InvokeRepeating ( "Refresh", 0, 2 );
        StartCoroutine ( SetArtwork ());
    }
Пример #9
0
        public void Initialize()
        {
            GoldTree.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.ForegroundColor = ConsoleColor.White;

            Console.WriteLine("                  " + PrettyVersion);
            Console.WriteLine();

            try
            {
                UserAdMessage = new List <string>();

                WebClient client2 = new WebClient();

                Stream       stream2 = client2.OpenRead("https://raw.github.com/JunioriRetro/Gold-Tree-Emulator/master/useradtype.txt");
                StreamReader reader2 = new StreamReader(stream2);

                String content2 = reader2.ReadLine();

                try
                {
                    UserAdType = int.Parse(content2);
                }
                catch { }

                WebClient client3 = new WebClient();

                Stream       stream3 = client3.OpenRead("https://raw.github.com/JunioriRetro/Gold-Tree-Emulator/master/useradmessage.txt");
                StreamReader reader3 = new StreamReader(stream3);

                string line2;
                while ((line2 = reader3.ReadLine()) != null)
                {
                    UserAdMessage.Add(line2);
                }

                WebClient client4 = new WebClient();

                Stream       stream4 = client4.OpenRead("https://raw.github.com/JunioriRetro/Gold-Tree-Emulator/master/useradlink.txt");
                StreamReader reader4 = new StreamReader(stream4);

                String content4 = reader4.ReadLine();

                UserAdLink = content4;

                try
                {
                    WebClient    client = new WebClient();
                    Stream       stream = client.OpenRead("https://raw.github.com/JunioriRetro/Gold-Tree-Emulator/master/consoleads.txt");
                    StreamReader reader = new StreamReader(stream);

                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.StartsWith(":"))
                        {
                            string[] Params = line.Split(new char[]
                            {
                                ' '
                            });

                            if (Params[0] == ":textcolor")
                            {
                                if (!string.IsNullOrEmpty(Params[1]))
                                {
                                    ConsoleColor Color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), Params[1]);
                                    Console.ForegroundColor = Color;
                                }
                            }

                            else if (Params[0] == ":colorchangingtext")
                            {
                                string text = line.Substring(Params[0].Length + Params[1].Length + Params[2].Length + Params[3].Length + Params[4].Length + 5);
                                RainbowText(text, IntToArray(Params[1]), 0, int.Parse(Params[2]), 0, int.Parse(Params[3]), bool.Parse(Params[4]), -1);
                            }
                        }
                        else
                        {
                            Console.WriteLine(line);
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                    }
                }
                catch
                {
                }
            }
            catch
            {
                Console.WriteLine("Sad cant find ads :(");
            }

            Console.ResetColor();

            try
            {
                GoldTree.Configuration = new ConfigurationData("config.conf");

                DateTime now = DateTime.Now;

                //Lookds = new Random().Next(Int32.MaxValue).ToString();

                DatabaseServer dbServer = new DatabaseServer(GoldTree.GetConfig().data["db.hostname"], uint.Parse(GoldTree.GetConfig().data["db.port"]), GoldTree.GetConfig().data["db.username"], GoldTree.GetConfig().data["db.password"]);
                Database       database = new Database(GoldTree.GetConfig().data["db.name"], uint.Parse(GoldTree.GetConfig().data["db.pool.minsize"]), uint.Parse(GoldTree.GetConfig().data["db.pool.maxsize"]));
                GoldTree.DatabaseManager = new DatabaseManager(dbServer, database);

                try
                {
                    using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("UPDATE users SET online = '0'");
                        dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0'");

                        DataRow DataRow;
                        DataRow = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'fw_count'");

                        DataRow DataRow2;
                        DataRow2 = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'extra_data'");

                        if (DataRow != null || DataRow2 != null)
                        {
                            if (DoYouWantContinue("Remember get backups before continue! Do you want continue? [Y/N]"))
                            {
                                if (DataRow != null)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!");
                                    Console.ForegroundColor = ConsoleColor.Gray;
                                    Console.Write("Updating items (Fireworks) ...");

                                    dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_firework");
                                    dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_firework` (`item_id` int(10) unsigned NOT NULL, `fw_count` int(10) NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");

                                    DataTable dataTable = dbClient.ReadDataTable("SELECT Id, fw_count FROM items;");

                                    int fails1 = 0;

                                    if (dataTable != null)
                                    {
                                        foreach (DataRow dataRow in dataTable.Rows)
                                        {
                                            try
                                            {
                                                if (dataRow != null && !string.IsNullOrEmpty(dataRow["Id"].ToString()) && !string.IsNullOrEmpty(dataRow["fw_count"].ToString()) && (uint)dataRow["Id"] > 0 && (int)dataRow["fw_count"] > 0)
                                                {
                                                    uint id       = (uint)dataRow["Id"];
                                                    int  wf_count = (int)dataRow["fw_count"];
                                                    if (wf_count > 0)
                                                    {
                                                        dbClient.AddParamWithValue("fkey" + id, id);
                                                        dbClient.AddParamWithValue("fvalue" + id, wf_count);
                                                        dbClient.ExecuteQuery("INSERT INTO items_firework(item_id, fw_count) VALUES (@fkey" + id + ", @fvalue" + id + ")");
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("OOPS! Error when updating.. Firework count lost :( Lets continue...");
                                                Logging.LogItemUpdateError(ex.ToString());
                                                fails1++;
                                            }
                                        }
                                    }

                                    if (fails1 > 0 && !DoYouWantContinue("Failed update " + fails1 + " item firework count. Do you want continue? YOU LOST THEIR ITEMS FIREWORK COUNT! [Y/N]"))
                                    {
                                        Logging.WriteLine("Press any key to shut down ...");
                                        Console.ReadKey(true);
                                        GoldTree.Destroy();
                                        Logging.WriteLine("Press any key to close window ...");
                                        Console.ReadKey(true);
                                        Environment.Exit(0);
                                        return;
                                    }

                                    if (dataTable != null)
                                    {
                                        dataTable.Clear();
                                    }

                                    dataTable = null;

                                    dbClient.ExecuteQuery("ALTER TABLE items DROP fw_count");

                                    Console.WriteLine("completed!");
                                }

                                if (DataRow2 != null)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!");
                                    Console.ForegroundColor = ConsoleColor.Gray;
                                    Console.Write("Updating items (Extra data) ...");

                                    dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_extra_data");
                                    dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_extra_data` (`item_id` int(10) unsigned NOT NULL, `extra_data` text NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");

                                    DataTable dataTable2 = dbClient.ReadDataTable("SELECT Id, extra_data FROM items;");

                                    int fails2 = 0;

                                    if (dataTable2 != null)
                                    {
                                        foreach (DataRow dataRow in dataTable2.Rows)
                                        {
                                            try
                                            {
                                                if (dataRow != null && !string.IsNullOrEmpty(dataRow["Id"].ToString()) && !string.IsNullOrEmpty(dataRow["extra_data"].ToString()) && (uint)dataRow["Id"] > 0)
                                                {
                                                    uint   id         = (uint)dataRow["Id"];
                                                    string extra_data = (string)dataRow["extra_data"];
                                                    if (!string.IsNullOrEmpty(extra_data))
                                                    {
                                                        dbClient.AddParamWithValue("ekey" + id, id);
                                                        dbClient.AddParamWithValue("evalue" + id, extra_data);
                                                        dbClient.ExecuteQuery("INSERT INTO items_extra_data(item_id, extra_data) VALUES (@ekey" + id + ", @evalue" + id + ")");
                                                    }
                                                    Console.WriteLine("Step 1 | ID: " + id + " | Extra data: " + extra_data);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("OOPS! Error when updating.. Extra data lost :( Lets continue...");
                                                Logging.LogItemUpdateError(ex.ToString());
                                                fails2++;
                                            }
                                        }
                                    }

                                    if (dataTable2 != null)
                                    {
                                        dataTable2.Clear();
                                    }

                                    dataTable2 = null;

                                    if (fails2 > 0 && !DoYouWantContinue("Failed update " + fails2 + " item extra data. Do you want continue? YOU LOST THEIR ITEMS EXTRA DATA! [Y/N]"))
                                    {
                                        Logging.WriteLine("Press any key to shut down ...");
                                        Console.ReadKey(true);
                                        GoldTree.Destroy();
                                        Logging.WriteLine("Press any key to close window ...");
                                        Console.ReadKey(true);
                                        Environment.Exit(0);
                                        return;
                                    }

                                    dbClient.ExecuteQuery("ALTER TABLE items DROP extra_data");

                                    Console.WriteLine("completed!");
                                }
                            }
                            else
                            {
                                Logging.WriteLine("Press any key to shut down ...");
                                Console.ReadKey(true);
                                GoldTree.Destroy();
                                Logging.WriteLine("Press any key to close window ...");
                                Console.ReadKey(true);
                                Environment.Exit(0);
                                return;
                            }
                        }
                    }
                    //GoldTree.ConnectionManage.method_7();
                    GoldTree.Internal_Game.ContinueLoading();
                }
                catch { }

                GoldTree.Internal_Game = new Game(int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]));

                GoldTree.PacketManager = new PacketManager();

                GoldTree.PacketManager.Handshake();

                GoldTree.PacketManager.Messenger();

                GoldTree.PacketManager.Navigator();

                GoldTree.PacketManager.RoomsAction();
                GoldTree.PacketManager.RoomsAvatar();
                GoldTree.PacketManager.RoomsChat();
                GoldTree.PacketManager.RoomsEngine();
                GoldTree.PacketManager.RoomsFurniture();
                GoldTree.PacketManager.RoomsPets();
                GoldTree.PacketManager.RoomsPools();
                GoldTree.PacketManager.RoomsSession();
                GoldTree.PacketManager.RoomsSettings();

                GoldTree.PacketManager.Catalog();
                GoldTree.PacketManager.Marketplace();
                GoldTree.PacketManager.Recycler();

                GoldTree.PacketManager.Quest();

                GoldTree.PacketManager.InventoryAchievements();
                GoldTree.PacketManager.InventoryAvatarFX();
                GoldTree.PacketManager.InventoryBadges();
                GoldTree.PacketManager.InventoryFurni();
                GoldTree.PacketManager.InventoryPurse();
                GoldTree.PacketManager.InventoryTrading();

                GoldTree.PacketManager.Avatar();
                GoldTree.PacketManager.Users();
                GoldTree.PacketManager.Register();

                GoldTree.PacketManager.Help();

                GoldTree.PacketManager.Sound();

                GoldTree.PacketManager.Wired();

                GoldTree.PacketManager.Jukebox();

                GoldTree.MusListener    = new MusListener(GoldTree.GetConfig().data["mus.tcp.bindip"], int.Parse(GoldTree.GetConfig().data["mus.tcp.port"]), GoldTree.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
                GoldTree.SocketsManager = new SocketsManager(GoldTree.GetConfig().data["game.tcp.bindip"], int.Parse(GoldTree.GetConfig().data["game.tcp.port"]), int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]));
                //ConnectionManage = new ConnectionHandeling(GoldTree.GetConfig().data["game.tcp.port"], int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]), int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]), true);
                GoldTree.SocketsManager.method_3().method_0();
                //ConnectionManage.init();
                //ConnectionManage.Start();

                /*try
                 * {
                 *  if (int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) < 1 || int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) > 2)
                 *  {
                 *      Console.ForegroundColor = ConsoleColor.Red;
                 *      Logging.WriteLine("Erroreita ei raportoida automaattisesti!!!");
                 *      Console.ForegroundColor = ConsoleColor.Gray;
                 *  }
                 *  if (int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) == 1)
                 *  {
                 *      Console.ForegroundColor = ConsoleColor.Green;
                 *      Logging.WriteLine("Kaikki errorit reportoidaan automaattisesti");
                 *      Console.ForegroundColor = ConsoleColor.Gray;
                 *  }
                 *  if (int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) > 1)
                 *  {
                 *      Console.ForegroundColor = ConsoleColor.Green;
                 *      Logging.WriteLine("Vain kritikaaliset virheiden reportoidaan automaattisesti");
                 *      Console.ForegroundColor = ConsoleColor.Gray;
                 *  }
                 * }
                 * catch
                 * {
                 *  Console.ForegroundColor = ConsoleColor.Red;
                 *  Logging.WriteLine("Erroreita ei raportoida automaattisesti!!!");
                 *  Console.ForegroundColor = ConsoleColor.Gray;
                 * }*/

                TimeSpan timeSpan = DateTime.Now - now;
                Logging.WriteLine(string.Concat(new object[]
                {
                    "Server -> READY! (",
                    timeSpan.Seconds,
                    " s, ",
                    timeSpan.Milliseconds,
                    " ms)"
                }));
                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);
                GoldTree.Destroy();
            }
            catch (InvalidOperationException ex)
            {
                Logging.WriteLine("Failed to initialize GoldTreeEmulator: " + ex.Message);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                GoldTree.Destroy();
            }
        }
Пример #10
0
        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();
            }
        }
Пример #11
0
 public static void Destroy()
 {
     Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
     Logging.WriteLine("Destroying EssentialEmu environment...");
     if (Essential.GetGame() != null)
     {
         Essential.GetGame().ContinueLoading();
         Essential.Internal_Game = null;
     }
     if (Essential.GetSocketsManager() != null)
     {
         Logging.WriteLine("Destroying connection manager.");
         Essential.GetSocketsManager().method_3().method_2();
         //Essential.smethod_14().Destroy();
         Essential.GetSocketsManager().method_0();
         Essential.SocketsManager = null;
     }
     if (Essential.GetDatabase() != null)
     {
         try
         {
             Logging.WriteLine("Destroying database manager.");
             MySqlConnection.ClearAllPools();
             Essential.DatabaseManager = null;
         }
         catch
         {
         }
     }
     Logging.WriteLine("Uninitialized successfully. Closing.");
 }
Пример #12
0
        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();
            }
        }
Пример #13
0
        public void Initialize()
        {
            if (!Licence.smethod_0(true))
            {
                GoldTree.ServerStarted = DateTime.Now;

                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine();
                //Console.WriteLine("        ______  _                       _          _______             "); //Based to phoenix
                //Console.WriteLine("       (_____ \\| |                     (_)        (_______)            "); //Based to phoenix
                //Console.WriteLine("        _____) ) | _   ___   ____ ____  _ _   _    _____   ____  _   _ "); //Based to phoenix
                //Console.WriteLine("       |  ____/| || \\ / _ \\ / _  )  _ \\| ( \\ / )  |  ___) |    \\| | | |"); //Based to phoenix
                //Console.WriteLine("       | |     | | | | |_| ( (/ /| | | | |) X (   | |_____| | | | |_| |"); //Based to phoenix
                //Console.WriteLine("       |_|     |_| |_|\\___/ \\____)_| |_|_(_/ \\_)  |_______)_|_|_|\\____|"); //Based to phoenix
                Console.WriteLine("                      _______   _________   ______ ");
                Console.WriteLine("                     |  _____| |___   ___| | _____|");
                Console.WriteLine("                     | |  ___      | |     | |____");
                Console.WriteLine("                     | | |_  |     | |     |  ____|");
                Console.WriteLine("                     | |___| |     | |     | |____");
                Console.WriteLine("                     |_______|     |_|     |______|");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("                  " + PrettyVersion);
                Console.WriteLine();
                Console.ResetColor();

                try
                {
                    GoldTree.Configuration = new ConfigurationData("config.conf");
                    DateTime now = DateTime.Now;
                    string_6 = GetConfig().data["GTE.username"];
                    string_7 = GetConfig().data["GTE.password"];
                    //Lookds = new Random().Next(Int32.MaxValue).ToString();
                    int num = string_6.Length * string_7.Length;

                    if (string_6 == "" || string_7 == "" || LicenseTools.Boolean_7)
                    {
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.Red;
                        GoldTree.Destroy("Invalid Licence details found #0001", false);
                    }
                    else
                    {
                        LicenseTools.String_6 = GoldTree.string_6;
                        LicenseTools.String_3 = GoldTree.string_7;
                        string text = new Random().Next(Int32.MaxValue).ToString();
                        text = Licence.smethod_1(text, this.string_3);

                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.Gray;
                        string str = new Random().Next(Int32.MaxValue).ToString();//text.Substring(32, 32);
                        str = GoldTree.smethod_0(str + GoldTree.string_6);
                        str = GoldTree.smethod_0(str + "4g");
                        str = GoldTree.smethod_1(str + GoldTree.string_7);
                        string b = GoldTree.smethod_0(num.ToString());

                        DatabaseServer Message3_ = new DatabaseServer(GoldTree.GetConfig().data["db.hostname"], uint.Parse(GoldTree.GetConfig().data["db.port"]), GoldTree.GetConfig().data["db.username"], GoldTree.GetConfig().data["db.password"]);
                        text = "r4r43mfgp3kkkr3mgprekw[gktp6ijhy[h]5h76ju6j7uj7";//text.Substring(64, 96);
                        Database Message2_ = new Database(GoldTree.GetConfig().data["db.name"], uint.Parse(GoldTree.GetConfig().data["db.pool.minsize"]), uint.Parse(GoldTree.GetConfig().data["db.pool.maxsize"]));
                        GoldTree.DatabaseManager = new DatabaseManager(Message3_, Message2_);

                        try
                        {
                            using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
                            {
                                @class.ExecuteQuery("UPDATE users SET online = '0'");
                                @class.ExecuteQuery("UPDATE rooms SET users_now = '0'");
                            }
                            GoldTree.ConnectionManage.method_7();
                            GoldTree.Game.ContinueLoading();
                        }
                        catch
                        {
                        }

                        LicenseTools.String_1 = text;
                        GoldTree.Game         = new Game(int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]));
                        string text2 = LicenseTools.String_5 + GoldTree.smethod_0((LicenseTools.String_6.Length * 10).ToString());
                        text2 += GoldTree.smethod_0((LicenseTools.String_3.Length % 10).ToString());

                        GoldTree.class117_0 = new PacketManager();
                        GoldTree.class117_0.Handshake();
                        GoldTree.class117_0.Messenger();
                        GoldTree.class117_0.Navigator();
                        GoldTree.class117_0.RoomsAction();
                        GoldTree.class117_0.RoomsAvatar();
                        GoldTree.class117_0.RoomsChat();
                        GoldTree.class117_0.RoomsEngine();
                        GoldTree.class117_0.RoomsFurniture();
                        GoldTree.class117_0.RoomsPets();
                        GoldTree.class117_0.RoomsPools();
                        GoldTree.class117_0.RoomsSession();
                        GoldTree.class117_0.RoomsSettings();
                        GoldTree.class117_0.Catalog();
                        GoldTree.class117_0.Marketplace();
                        GoldTree.class117_0.Recycler();
                        GoldTree.class117_0.Quest();
                        GoldTree.class117_0.InventoryAchievements();
                        GoldTree.class117_0.InventoryAvatarFX();
                        GoldTree.class117_0.InventoryBadges();
                        GoldTree.class117_0.InventoryFurni();
                        GoldTree.class117_0.InventoryPurse();
                        GoldTree.class117_0.InventoryTrading();
                        GoldTree.class117_0.Avatar();
                        GoldTree.class117_0.Users();
                        GoldTree.class117_0.Register();
                        GoldTree.class117_0.Help();
                        GoldTree.class117_0.Sound();
                        GoldTree.class117_0.Wired();
                        GoldTree.class117_0.Jukebox();
                    }

                    LicenseTools.int_12 = int.Parse(GoldTree.GetConfig().data["game.tcp.port"]);
                    LicenseTools.int_13 = int.Parse(GoldTree.GetConfig().data["mus.tcp.port"]);
                    try
                    {
                        LicenseTools.ProxyIP = GetConfig().data["game.tcp.proxyip"];
                    }
                    catch
                    {
                    }

                    GoldTree.MusListener      = new MusListener(GoldTree.GetConfig().data["mus.tcp.bindip"], LicenseTools.int_13, GoldTree.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
                    GoldTree.ConnectionManage = new SocketsManager(LicenseTools.string_33, LicenseTools.int_12, int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]));
                    GoldTree.ConnectionManage.method_3().method_0();

                    /*try
                     * {
                     *  if (int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) < 1 || int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) > 2)
                     *  {
                     *      Console.ForegroundColor = ConsoleColor.Red;
                     *      Logging.WriteLine("Erroreita ei raportoida automaattisesti!!!");
                     *      Console.ForegroundColor = ConsoleColor.Gray;
                     *  }
                     *  if (int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) == 1)
                     *  {
                     *      Console.ForegroundColor = ConsoleColor.Green;
                     *      Logging.WriteLine("Kaikki errorit reportoidaan automaattisesti");
                     *      Console.ForegroundColor = ConsoleColor.Gray;
                     *  }
                     *  if (int.Parse(GoldTree.GetConfig().data["automatic-error-report"]) > 1)
                     *  {
                     *      Console.ForegroundColor = ConsoleColor.Green;
                     *      Logging.WriteLine("Vain kritikaaliset virheiden reportoidaan automaattisesti");
                     *      Console.ForegroundColor = ConsoleColor.Gray;
                     *  }
                     * }
                     * catch
                     * {
                     *  Console.ForegroundColor = ConsoleColor.Red;
                     *  Logging.WriteLine("Erroreita ei raportoida automaattisesti!!!");
                     *  Console.ForegroundColor = ConsoleColor.Gray;
                     * }*/

                    TimeSpan timeSpan = DateTime.Now - now;
                    Logging.WriteLine(string.Concat(new object[]
                    {
                        "Server -> READY! (",
                        timeSpan.Seconds,
                        " s, ",
                        timeSpan.Milliseconds,
                        " ms)"
                    }));
                    Console.Beep();
                }
                catch (KeyNotFoundException)
                {
                    Logging.WriteLine("Failed to boot, key not found.");
                    Logging.WriteLine("Press any key to shut down ...");
                    Console.ReadKey(true);
                    GoldTree.smethod_16();
                }
                catch (InvalidOperationException ex)
                {
                    if (ex.Message.Contains("goldtree"))
                    {
                        Logging.WriteLine("Failed to initialize GoldTreeEmulator");
                    }
                    else
                    {
                        Logging.WriteLine("Failed to initialize GoldTreeEmulator: " + ex.Message);
                    }
                    Logging.WriteLine("Press any key to shut down ...");
                    Console.ReadKey(true);
                    GoldTree.smethod_16();
                }
            }
        }
Пример #14
0
        public void Initialize()
        {
            HabboIM.ServerStarted = DateTime.Now;
            Console.Title = "HabboIM Emulator wird gestartet..";
            Console.SetWindowPosition(0, 0);
            Console.SetWindowSize(100, 20);
            Console.BackgroundColor = ConsoleColor.Black;
            Console.CursorVisible = false;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Red;
             try
             {

            Console.WriteLine();
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("                               @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine("");

            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*************************************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.WriteLine("");

            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.Write("                               @@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@"); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("*****************"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("@@@ "); Console.WriteLine("");
            Console.WriteLine("                               @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("                             ");
            Console.WriteLine("                                       " + Version);
            Console.WriteLine("                                   " + Developer);
            Console.WriteLine("                                         Lizenz: " + licence);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("____________________________________________________________________________________________________");
            Console.WriteLine();
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Lotto gestartet! Nächste Ziehung um " + (hour_lastlotto+1) + ":00 Uhr");
            Console.ResetColor();

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            try
            {
                DateTime now = DateTime.Now;
                try
                {
                    HabboIM.Configuration = new ConfigurationData("config.conf");

                    Check();

                    DatabaseServer dbServer = new DatabaseServer(HabboIM.GetConfig().data["db.hostname"], uint.Parse(HabboIM.GetConfig().data["db.port"]), HabboIM.GetConfig().data["db.username"], HabboIM.GetConfig().data["db.password"]);
                    Database database = new Database(HabboIM.GetConfig().data["db.name"], uint.Parse(HabboIM.GetConfig().data["db.pool.minsize"]), uint.Parse(HabboIM.GetConfig().data["db.pool.maxsize"]));
                    HabboIM.DatabaseManager = new DatabaseManager(dbServer, database);
                }
                catch
                {
                    Logging.WriteLine("Der Emulator wurde falsch konfiguriert!");
                    Logging.WriteLine("Press any key to shut down ...");
                    Console.ReadKey(true);
                    HabboIM.Destroy();

                }
                try
                {
                    using (DatabaseClient dbClient = HabboIM.GetDatabase().GetClient())
                    {
                        dbClient.ExecuteQuery("SET @@global.sql_mode= '';");
                        dbClient.ExecuteQuery("UPDATE users SET online = '0' WHERE online = '1' ");
                        dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0' WHERE users_now > 0");

                        DataRow DataRow;
                        DataRow = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'fw_count'");

                        DataRow DataRow2;
                        DataRow2 = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'extra_data'");

                        if (DataRow != null || DataRow2 != null)
                        {
                            if (DoYouWantContinue("Remember get backups before continue! Do you want continue? [Y/N]"))
                            {
                                if (DataRow != null)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!");
                                    Console.ForegroundColor = ConsoleColor.Gray;
                                    Console.Write("Items werden geupdatet (Feuerwerke) ...");

                                    dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_firework", int.MaxValue);
                                    dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_firework` (`item_id` int(10) unsigned NOT NULL, `fw_count` int(10) NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;", int.MaxValue);
                                    dbClient.ExecuteQuery("INSERT INTO items_firework SELECT Id, fw_count FROM items WHERE fw_count > 0;", int.MaxValue);
                                    dbClient.ExecuteQuery("ALTER TABLE items DROP fw_count", int.MaxValue);

                                    Console.WriteLine("Erfolgreich!");
                                }

                                if (DataRow2 != null)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!");
                                    Console.ForegroundColor = ConsoleColor.Gray;
                                    Console.Write("Items werden geupdatet (Extra data) ...");

                                    dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_extra_data", int.MaxValue);
                                    dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_extra_data` (`item_id` int(10) unsigned NOT NULL, `extra_data` text NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;", int.MaxValue);
                                    dbClient.ExecuteQuery("INSERT INTO items_extra_data SELECT Id, extra_data FROM items WHERE extra_data != '';", int.MaxValue);
                                    dbClient.ExecuteQuery("ALTER TABLE items DROP extra_data", int.MaxValue);

                                    Console.WriteLine("Erfolgreich!");
                                }

                            }
                            else
                            {
                                Console.BackgroundColor = ConsoleColor.Black;
                                Logging.WriteLine("Press any key to shut down ...");
                                Console.ReadKey(true);
                                HabboIM.Destroy();
                                Logging.WriteLine("Press any key to close window ...");
                                Console.ReadKey(true);
                                Environment.Exit(0);
                                return;
                            }
                        }
                    }
                    //HabboIM.ConnectionManage.method_7();
                    HabboIM.Internal_Game.ContinueLoading();
                }
                catch { }
                Console.BackgroundColor = ConsoleColor.Black;

                try
                {
                    HabboIM.Internal_Game = new Game(int.Parse(HabboIM.GetConfig().data["game.tcp.conlimit"]));
                }
                catch
                {

                    Console.BackgroundColor = ConsoleColor.Black;
                    Logging.WriteLine("Fehler bei den Permissions");
                    Logging.WriteLine("Press any key to shut down ...");
                    Console.ReadKey(true);
                    HabboIM.Destroy();

                }

                try
                {
                    HabboIM.PacketManager = new PacketManager();

                    HabboIM.PacketManager.Handshake();

                    HabboIM.PacketManager.Messenger();

                    HabboIM.PacketManager.Navigator();

                    HabboIM.PacketManager.RoomsAction();
                    HabboIM.PacketManager.RoomsAvatar();
                    HabboIM.PacketManager.RoomsChat();
                    HabboIM.PacketManager.RoomsEngine();
                    HabboIM.PacketManager.RoomsFurniture();
                    HabboIM.PacketManager.RoomsPets();
                    HabboIM.PacketManager.RoomsPools();
                    HabboIM.PacketManager.RoomsSession();
                    HabboIM.PacketManager.RoomsSettings();

                    HabboIM.PacketManager.Catalog();
                    HabboIM.PacketManager.Marketplace();
                    HabboIM.PacketManager.Recycler();

                    HabboIM.PacketManager.Quest();

                    HabboIM.PacketManager.InventoryAchievements();
                    HabboIM.PacketManager.InventoryAvatarFX();
                    HabboIM.PacketManager.InventoryBadges();
                    HabboIM.PacketManager.InventoryFurni();
                    HabboIM.PacketManager.InventoryPurse();
                    HabboIM.PacketManager.InventoryTrading();

                    HabboIM.PacketManager.Avatar();
                    HabboIM.PacketManager.Users();
                    HabboIM.PacketManager.Register();

                    HabboIM.PacketManager.Help();

                    HabboIM.PacketManager.Sound();

                    HabboIM.PacketManager.Wired();

                    HabboIM.PacketManager.Jukebox();

                    HabboIM.PacketManager.FriendStream();

                }
                catch
                {
                    Console.BackgroundColor = ConsoleColor.Black;
                    Logging.WriteLine("Fehler bei wat weiß ich.");
                    Logging.WriteLine("Press any key to shut down ...");
                    Console.ReadKey(true);
                    HabboIM.Destroy();
                }
                try
                {
                    HabboIM.webSocketManager = new WebSocketServerManager(HabboIM.GetConfig().data["websockets.url"]);
                    HabboIM.MusListener = new MusListener(HabboIM.GetConfig().data["mus.tcp.bindip"], int.Parse(HabboIM.GetConfig().data["mus.tcp.port"]), HabboIM.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
                    HabboIM.SocketsManager = new SocketsManager(HabboIM.GetConfig().data["game.tcp.bindip"], int.Parse(HabboIM.GetConfig().data["game.tcp.port"]), int.Parse(HabboIM.GetConfig().data["game.tcp.conlimit"]));
                    HabboIM.SocketsManager.method_3().method_0();
                }
                catch
                {
                    Console.BackgroundColor = ConsoleColor.Black;
                    Logging.WriteLine("MUS Verbindung fehlgeschlagen!");
                    Logging.WriteLine("Press any key to shut down ...");
                    Console.ReadKey(true);
                    HabboIM.Destroy();

                }
                TimeSpan timeSpan = DateTime.Now - now;
                Console.BackgroundColor = ConsoleColor.Black;
                Logging.WriteLine(string.Concat(new object[]
                    {
                        "HabboIM -> BEREIT! (",
                        timeSpan.Seconds,
                        " s, ",
                        timeSpan.Milliseconds,
                        " ms)"
                    }));
                Console.Beep();
            }
            catch (KeyNotFoundException KeyNotFoundException)
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Logging.WriteLine("Failed to boot, key not found: " + KeyNotFoundException);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                HabboIM.Destroy();
            }

            catch (InvalidOperationException ex)
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Logging.WriteLine("Failed to initialize Unicorn: " + ex.Message);
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                HabboIM.Destroy();
            }

             }
            catch
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Logging.WriteLine("Configuration not found ");
                Logging.WriteLine("Press any key to shut down ...");
                Console.ReadKey(true);
                HabboIM.Destroy();
            }
        }