Maybe we'll remove this.
Inheritance: SagaLib.Client
Example #1
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("              Saga Map Server - Internal Beta Version                 ");
            Console.WriteLine("             (C)2007 The Saga Project Development Team                ");
            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 #2
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("              Saga Map Server - Internal Beta Version                 ");
            Console.WriteLine("             (C)2007 The Saga Project Development Team                ");
            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);
            }
        }