Beispiel #1
0
        private static readonly Logger Logger = LogManager.CreateLogger(); // logger instance.

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;    // Watch for any unhandled exceptions.
            Thread.CurrentThread.CurrentCulture         = CultureInfo.InvariantCulture; // Use invariant culture - we have to set it explicitly for every thread we create to prevent any mpq-reading problems (mostly because of number formats).

            Console.ForegroundColor = ConsoleColor.Yellow;
            PrintBanner();        // print ascii banner.
            PrintLicense();       // print license text.
            Console.ResetColor(); // reset color back to default.

            InitLoggers();        // init logging facility.

            Logger.Info("mooege v{0} warming-up..", Assembly.GetExecutingAssembly().GetName().Version);
            Logger.Info("Required client version: {0}.", VersionInfo.MooNet.RequiredClientVersion);

            // init openssl & wrapper.
            try
            {
                Logger.Info("Found OpenSSL version {0}.", OpenSSL.Core.Version.Library.ToString());
            }
            catch (Exception e)
            {
                Logger.ErrorException(e, "OpenSSL init error.");
                Console.ReadLine();
                return;
            }

            // prefill the database.
            Common.Storage.AccountDataBase.SessionProvider.RebuildSchema();
            if (!DBSessions.AccountSession.Query <DBAccount>().Any())
            {
                Logger.Info("Initing new database, creating first owner account (test@,123456)");
                var account     = AccountManager.CreateAccount("test@", "123456", "test", Account.UserLevels.Owner);
                var gameAccount = GameAccountManager.CreateGameAccount(account);
                account.DBAccount.DBGameAccounts.Add(gameAccount.DBGameAccount);
                account.SaveToDB();
            }

            // init MPQStorage.
            if (!MPQStorage.Initialized)
            {
                Logger.Fatal("Cannot run servers as MPQStorage failed initialization.");
                Console.ReadLine();
                return;
            }

            // load item database.
            Logger.Info("Loading item database..");
            Logger.Trace("Item database loaded with a total of {0} item definitions.", ItemGenerator.TotalItems);

            // load achievements database.
            Logger.Info("Loading achievements database..");
            Logger.Trace("Achievement file parsed with a total of {0} achievements and {1} criteria in {2} categories.",
                         AchievementManager.TotalAchievements, AchievementManager.TotalCriteria, AchievementManager.TotalCategories);


            Logger.Info("Type '!commands' for a list of available commands.");

            StartupServers(); // startup the servers
        }
Beispiel #2
0
        public bool CreateAccount(string email, string password, string battleTag)
        {
            if (string.IsNullOrEmpty(email))
            {
                throw new FaultException(new FaultReason("Email parameter can not be null or empty."));
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new FaultException(new FaultReason("Password parameter can not be null or empty."));
            }

            if (string.IsNullOrEmpty(battleTag))
            {
                throw new FaultException(new FaultReason("BattleTag parameter can not be null or empty."));
            }

            if (password.Length < 8 || password.Length > 16)
            {
                throw new FaultException(new FaultReason("Password should be a minimum of 8 and a maximum of 16 characters."));
            }

            if (AccountManager.GetAccountByEmail(email.ToLower()) != null)
            {
                throw new FaultException(new FaultReason(string.Format("An account already exists for email address {0}.", email)));
            }

            var account     = AccountManager.CreateAccount(email, password, battleTag);
            var gameAccount = GameAccountManager.CreateGameAccount(account);

            return(true);
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            // Watch for unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; // Use invariant culture - we have to set it explicitly for every thread we create.


            Console.ForegroundColor = ConsoleColor.Yellow;
            PrintBanner();
            PrintLicense();
            Console.ResetColor();

            InitLoggers(); // init logging facility.

            Logger.Info("mooege v{0} warming-up..", Assembly.GetExecutingAssembly().GetName().Version);

            try
            {
                Logger.Info("Found OpenSSL version {0}.", OpenSSL.Core.Version.Library.ToString());
            }
            catch (Exception e)
            {
                Logger.ErrorException(e, "OpenSSL Error");
                Console.ReadLine();
                return;
            }


            //Prefilling Database
            Common.Storage.AccountDataBase.SessionProvider.RebuildSchema();
            if (!DBSessions.AccountSession.Query <DBAccount>().Any())
            {
                Logger.Info("New Database, creating first Test account (Test@,testpass)");
                var account     = AccountManager.CreateAccount("test@", "testpass", "test", Account.UserLevels.Admin);
                var gameAccount = GameAccountManager.CreateGameAccount(account);
                account.DBAccount.DBGameAccounts.Add(gameAccount.DBGameAccount);
                account.SaveToDB();
            }


            if (!MPQStorage.Initialized)
            {
                Logger.Fatal("Cannot run servers as MPQStorage failed initialization.");
                Console.ReadLine();
                return;
            }

            Logger.Info("Loading item database..");
            Logger.Trace("Item database loaded with a total of {0} item definitions.", ItemGenerator.TotalItems);

            Logger.Info("Loading achievements database..");
            Logger.Trace("Achievement file parsed with a total of {0} achievements and {1} criteria in {2} categories.",
                         AchievementManager.TotalAchievements, AchievementManager.TotalCriteria, AchievementManager.TotalCategories);


            Logger.Info("Type '!commands' for a list of available commands");

            StartupServers();
        }