Ejemplo n.º 1
0
        public static void StartTheServer()
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.Green;
                zoneServer.Monsters = new List<NonPlayerCharacterClass>();
                zoneServer.Vendors = new List<VendingMachine>();
                zoneServer.Doors = new List<Doors>();

                using (SqlWrapper sqltester = new SqlWrapper())
                {
                    if (sqltester.SQLCheck() != SqlWrapper.DBCheckCodes.DBC_ok)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Database setup not correct");
                        Console.WriteLine("Error: #" + sqltester.lasterrorcode + " - " + sqltester.lasterrormessage);
                        Console.WriteLine("Please press Enter to exit.");
                        Console.ReadLine();
                        Process.GetCurrentProcess().Kill();
                    }
                    sqltester.CheckDBs();
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Loaded {0} items", ItemHandler.CacheAllItems());
                Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos());
                Console.WriteLine("Loaded {0} spawns", NonPlayerCharacterHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} vendors", VendorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} teleports", DoorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} statels", Statels.CacheAllStatels());

                LootHandler.CacheAllFromDB();
                Tradeskill.CacheItemNames();

                csc.AddScriptMembers();
                csc.CallMethod("Init", null);

                ThreadMgr.Start();
                zoneServer.Start();
                Console.ResetColor();
            }
            catch (MySqlException e)
            {
                Console.WriteLine("MySql Error. Server Cannot Start");
                Console.WriteLine("Exception: " + e.Message);
                string current = DateTime.Now.ToString("HH:mm:ss");
                StreamWriter logfile = File.AppendText("ZoneEngineLog.txt");
                logfile.WriteLine(current + " " + e.Source + " MySql Error. Server Cannot Start");
                logfile.WriteLine(current + " " + e.Source + " Exception: " + e.Message);
                logfile.Close();
                zoneServer.Stop();
                ThreadMgr.Stop();
                Process.GetCurrentProcess().Kill();
            }
        }