Example #1
0
        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            AppDomain.CurrentDomain.UnhandledException          += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Logger Log = new Logger("SagaLogin.log");

            Logger.defaultlogger    = Log;
            Logger.CurrentLogger    = Log;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("======================================================================");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("               Authenticate Server - Emulador Saga                ");
            Console.WriteLine("                 (C)2014 RO2GOTW Revival Project               ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("======================================================================");
            Console.ResetColor();
            Logger.ShowInfo("Starting Initialization...", null);
            Config.Instance.ReadConfig("Config/CharConfig.xml");

            AdditionFactory.Start("DB/additionDB.xml");
            Item.LoadItems("DB/itemDB.xml");
            LoginClientManager.Instance.Start();
            Global.clientMananger = (ClientManager)LoginClientManager.Instance;

            if (!StartUserDatabase() || !StartWorldDatabase())
            {
                Console.WriteLine("Shutting down in 20sec.");
                System.Threading.Thread.Sleep(20000);
                return;
            }
            Logger.defaultlogger.LogLevel = (Logger.LogContent)lcfg.LogLevel;
            Console.WriteLine("Successfully connected to the dbservers.");

            if (!LoginClientManager.Instance.StartNetwork(lcfg.Port))
            {
                Console.WriteLine("Error: cannot listen on port: " + lcfg.Port);
                Console.WriteLine("Shutting down in 20sec.");
                System.Threading.Thread.Sleep(20000);
                return;
            }


            Console.WriteLine("ONLINE: Aceptando clientes.");

            while (true)
            {
                // keep the connections to the database servers alive
                EnsureUserDB();
                EnsureCharDBs();

                // let new clients (max 10) connect
                LoginClientManager.Instance.NetworkLoop(10);

                // sleep 1ms
                System.Threading.Thread.Sleep(1);
            }
        }
Example #2
0
        public void AddAddition(Actor pc, uint id, bool deactivate)
        {
            List <SagaDB.Items.Bonus> bonus = AdditionFactory.GetBonus(id);

            foreach (SagaDB.Items.Bonus i in bonus)
            {
                AddBonus(pc, i, BonusType.Skill, deactivate, id);
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            Logger Log = new Logger("SagaMap.log");

            Logger.defaultlogger = Log;
            Logger.CurrentLogger = Log;
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Console.CancelKeyPress += new ConsoleCancelEventHandler(ShutingDown);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("======================================================================");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("                   Zone Server - Emulador Saga                ");
            Console.WriteLine("                 (C)2014 RO2GOTW Revival Project               ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("======================================================================");
            Console.ResetColor();
            Logger.ShowInfo("Starting Initialization...", null);
            lcfg = new MapConfig();
            Config.Instance.ReadConfig("Config/MapConfig.xml");
            AdditionFactory.Start("DB/additionDB.xml");
            Item.LoadItems("DB/itemDB.xml");
            WeaponFactory.Start("DB/weaponInfo.xml");
            PortalManager.Start("DB/portalDB.xml");

            Skills.SkillHandler.Initialize();

            MapClientManager.Instance.Start();
            Global.clientMananger = (ClientManager)MapClientManager.Instance;

            if (!StartDatabase())
            {
                Logger.ShowError("cannot connect to dbserver", null);
                Logger.ShowError("Shutting down in 20sec.", null);
                System.Threading.Thread.Sleep(20000);
                return;
            }

            MapManager.Instance.LoadMaps(lcfg.HostedMaps);
            MobFactory.Start("DB/MobDB.xml");
            ScriptManager = new ScriptManager();

            LoginServerSession            = new LoginSession(lcfg.LoginServerHost, lcfg.LoginServerPort);
            Logger.defaultlogger.LogLevel = (Logger.LogContent)lcfg.LogLevel;

            while (LoginServerSession.state == LoginSession.SESSION_STATE.NOT_IDENTIFIED)
            {
                System.Threading.Thread.Sleep(10);
            }

            if (LoginServerSession.state == LoginSession.SESSION_STATE.REJECTED)
            {
                Logger.ShowWarning("Shutting down in 5sec.", null);
                MapClientManager.Instance.Stop();
                System.Threading.Thread.Sleep(5000);
                Process.GetCurrentProcess().Close();
                Environment.Exit(0);
                return;
            }

            if (!MapClientManager.Instance.StartNetwork(lcfg.Port))
            {
                Logger.ShowError("cannot listen on port: " + lcfg.Port, null);
                MapClientManager.Instance.Stop();
                Logger.ShowError("Shutting down in 5sec.", null);
                System.Threading.Thread.Sleep(5000);
                Process.GetCurrentProcess().Close();
                Environment.Exit(0);
                return;
            }

            Logger.ShowInfo("Accepting clients, MAP SERVER IS ONLINE!", null);

            // General poonism by will. Temp solution to test
            ExperienceManager.Instance.LoadTable("DB/exp.xml");


            while (true)
            {
                if (!LoginServerSession.netIO.sock.Connected)
                {
                    LoginServerSession.netIO.sock.Close();
                    LoginServerSession.netIO.sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    LoginServerSession.Connect(LoginServerSession.netIO.sock, lcfg.LoginServerHost, lcfg.LoginServerPort);
                }
                EnsureCharDB();

                MapClientManager.Instance.NetworkLoop(10);


                System.Threading.Thread.Sleep(1);
            }
        }
Example #4
0
        public string GetResult()
        {
            string[] str = expression.Split(new char[4] {
                '+', '-', '/', '*'
            });
            string result = null;

            if (str.Length == 1)
            {
                return(Convert.ToDouble(str[0]).ToString());
            }
            else
            {
                //第一个数带符号问题
                if (str.Length == 3)
                {
                    str[0] = "-" + str[1];
                    str[1] = str[2];
                }
                char c = expression.ToCharArray()[expression.IndexOf(str[0]) + str[0].Length];
                //string pattern = @"^-?\d+$";//判断整数?
                //Regex regex = new Regex(pattern);
                switch (c)
                {
                case '+':
                {
                    AdditionFactory additionFactory = new AdditionFactory();
                    Operation       operateAddition = additionFactory.CreateAddition(str[0], str[1]);
                    result = operateAddition.GetResult();
                    break;
                }

                case '-':
                {
                    SubtractionFactory subtractionFactory = new SubtractionFactory();
                    Operation          operateSubtraction = subtractionFactory.CreateSubtraction(str[0], str[1]);
                    result = operateSubtraction.GetResult();
                    break;
                }

                case '*':
                {
                    MultiplyFactory additionFactory = new MultiplyFactory();
                    Operation       operateMultiply = additionFactory.CreateMultiply(str[0], str[1]);
                    result = operateMultiply.GetResult();
                    break;
                }

                case '/':
                {
                    DivideFactory additionFactory = new DivideFactory();
                    Operation     operateDivide   = additionFactory.CreateDivide(str[0], str[1]);
                    result = operateDivide.GetResult();
                    break;
                }

                default: result = "error"; break;
                }
            }
            return(result.ToString());
        }