Esempio 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();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        private static void StartTheServer()
        {
            // TODO: Read playfield data, check which playfields have to be created, and create them
            // TODO: Cache neccessary Spawns and Mobs
            // TODO: Cache neccessary Doors
            // TODO: Cache neccessary statels
            // TODO: Cache Vendors

            // Console.WriteLine(Core.Playfields.Playfields.Instance.playfields[0].name);

            Console.WriteLine(csc.AddScriptMembers() + " chat commands loaded");
            zoneServer.Start(true, false);
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        public static void StartTheServer()
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.Green;

                // Log off all characters
                // TODO: make it playfield dependent
                Misc.CheckDatabase();

                Misc.LogOffAll();

                /* TODO: Readd the things, Algorithman
                 * 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;

                /* TODO: Readd when necessary classes are done again
                 */
                Console.WriteLine("Loaded {0} items", ItemLoader.CacheAllItems());
                Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos());

                // Console.WriteLine("Creaated {0} playfields", zoneServer.CreatePlayfields());

                /*
                 * 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());
                 */

                /* Same as above
                 * LootHandler.CacheAllFromDB();
                 * Tradeskill.CacheItemNames();
                 */
                csc.AddScriptMembers();
                csc.CallMethod("Init", null);

                zoneServer.Start(true, false);
                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();
                Process.GetCurrentProcess().Kill();
            }
        }