Beispiel #1
0
        protected override void OnTick()
        {
            bool shouldExit = false;

            try
            {
                shouldExit = Process(DateTime.UtcNow + TimeSpan.FromSeconds(CpuInterval * CpuPercent));

                if (shouldExit)
                {
                    Console.WriteLine("MyRunUO: Database statements compiled in {0:F2} seconds", (DateTime.UtcNow - m_StartTime).TotalSeconds);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("MyRunUO: {0}: Exception cought while processing", m_Stage);
                Console.WriteLine(e);
                shouldExit = true;
            }

            if (shouldExit)
            {
                m_Command.Enqueue(null);

                Stop();
                m_Timer = null;
            }
        }
Beispiel #2
0
        public static void TableCreation()
        {
            if (m_Command != null && !m_Command.HasCompleted)
            {
                return;
            }
            DateTime start = DateTime.Now;

            Console.WriteLine("MyRunUO: Creating tables");
            try
            {
                m_Command = new DatabaseCommandQueue("MyRunUO: Tables created in {0:F1} seconds", "MyRunUO Status Database Thread");
                m_Command.Enqueue("CREATE TABLE IF NOT EXISTS `myrunuo_characters` ( `char_id` int(10) unsigned NOT NULL, `char_name` varchar(255) NOT NULL, `char_str` smallint(3) unsigned NOT NULL, `char_dex` smallint(3) unsigned NOT NULL, `char_int` smallint(3) unsigned NOT NULL, `char_female` tinyint(1) NOT NULL, `char_counts` smallint(6) NOT NULL, `char_guild` varchar(255) DEFAULT NULL, `char_guildtitle` varchar(255) DEFAULT NULL, `char_nototitle` varchar(255) DEFAULT NULL, `char_bodyhue` smallint(5) unsigned DEFAULT NULL, `char_public` tinyint(1) NOT NULL, PRIMARY KEY (`char_id`))");
                m_Command.Enqueue("CREATE TABLE IF NOT EXISTS `myrunuo_characters_layers` ( `char_id` int(10) unsigned NOT NULL, `layer_id` tinyint(3) unsigned NOT NULL, `item_id` smallint(5) unsigned NOT NULL, `item_hue` smallint(5) unsigned NOT NULL, PRIMARY KEY (`char_id`,`layer_id`))");
                m_Command.Enqueue("CREATE TABLE IF NOT EXISTS `myrunuo_characters_skills` ( `char_id` int(10) unsigned NOT NULL, `skill_id` tinyint(3) NOT NULL, `skill_value` smallint(5) unsigned NOT NULL, PRIMARY KEY (`char_id`,`skill_id`),  KEY `skill_id` (`skill_id`))");
                m_Command.Enqueue("CREATE TABLE IF NOT EXISTS `myrunuo_guilds` ( `guild_id` smallint(5) unsigned NOT NULL, `guild_name` varchar(255) NOT NULL, `guild_abbreviation` varchar(8) DEFAULT NULL, `guild_website` varchar(255) DEFAULT NULL, `guild_charter` varchar(255) DEFAULT NULL, `guild_type` varchar(8) NOT NULL, `guild_wars` smallint(5) unsigned NOT NULL, `guild_members` smallint(5) unsigned NOT NULL, `guild_master` int(10) unsigned NOT NULL, PRIMARY KEY (`guild_id`))");
                m_Command.Enqueue("CREATE TABLE IF NOT EXISTS `myrunuo_guilds_wars` ( `guild_1` smallint(5) unsigned NOT NULL DEFAULT '0', `guild_2` smallint(5) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`guild_1`,`guild_2`), KEY `guild1` (`guild_1`), KEY `guild2` (`guild_2`))");
                m_Command.Enqueue("CREATE TABLE IF NOT EXISTS `myrunuo_status` ( `char_id` int(10) NOT NULL, PRIMARY KEY (`char_id`))");
            }
            catch (Exception e)
            {
                Console.WriteLine("MyRunUO: Error creating tables.");
                Console.WriteLine(e);
            }
            if (m_Command != null)
            {
                m_Command.Enqueue(null);
            }
        }
        public static void Begin()
        {
            if (m_Command != null && !m_Command.HasCompleted)
            {
                return;
            }

            DateTime start = DateTime.UtcNow;

            Console.WriteLine("MyRunUO: Updating status database");

            try
            {
                m_Command = new DatabaseCommandQueue("MyRunUO: Status database updated in {0:F1} seconds", "MyRunUO Status Database Thread");

                m_Command.Enqueue("DELETE FROM myrunuo_status");

                List <NetState> online = NetState.Instances;

                for (int i = 0; i < online.Count; ++i)
                {
                    NetState ns  = online[i];
                    Mobile   mob = ns.Mobile;

                    if (mob != null)
                    {
                        m_Command.Enqueue(String.Format("INSERT INTO myrunuo_status (char_id) VALUES ({0})", mob.Serial.Value.ToString()));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("MyRunUO: Error updating status database");
                Console.WriteLine(e);
            }

            if (m_Command != null)
            {
                m_Command.Enqueue(null);
            }
        }
Beispiel #4
0
        public void CheckConnection()
        {
            if (m_Command == null)
            {
                m_Command = new DatabaseCommandQueue("MyRunUO: Characeter database updated in {0:F1} seconds", "MyRunUO Character Database Thread");

                if (Config.LoadDataInFile)
                {
                    m_OpSkills  = GetUniqueWriter("skills", out m_SkillsPath);
                    m_OpLayers  = GetUniqueWriter("layers", out m_LayersPath);
                    m_OpMobiles = GetUniqueWriter("mobiles", out m_MobilesPath);

                    m_Command.Enqueue("TRUNCATE TABLE myrunuo_characters");
                    m_Command.Enqueue("TRUNCATE TABLE myrunuo_characters_layers");
                    m_Command.Enqueue("TRUNCATE TABLE myrunuo_characters_skills");
                }

                m_Command.Enqueue("TRUNCATE TABLE myrunuo_guilds");
                m_Command.Enqueue("TRUNCATE TABLE myrunuo_guilds_wars");
            }
        }