Exemple #1
0
        public void InitServer()
        {
            Configuration.Open();
            Configuration.GetGeneralConfig();
            Configuration.GetDatabaseConfig();
            Configuration.Close();

            Configuration.ShowConfigInLog();
            Configuration.CheckDatabaseConnection();

            if (GeoIpBlock.Enabled)
            {
                WriteLog(LogType.System, "Loading GeoIp data country", LogColor.Black);
                GeoIpBlock.LoadData();
            }

            IpBlockList.Initialize();

            IpFiltering = new IpFiltering()
            {
                CheckAccessTime  = Configuration.CheckAccessTime,
                IpLifetime       = Configuration.IpLifetime,
                IpMaxAccessCount = Configuration.IpMaxAccessCount,
                IpMaxAttempt     = Configuration.IpMaxAttempt
            };

            WriteLog(LogType.System, "Initializing scripts", LogColor.Blue);

            var lua = new LuaScript();

            lua.InitializeScript();

            OpCode.Initialize();

            TcpTransfer = new TcpTransfer()
            {
                GameIpAddress = Configuration.GameServerIp,
                GamePort      = Configuration.GameServerPort
            };

            TcpTransfer.InitClient();

            WriteLog(LogType.System, "Trying to connect to Game Server", LogColor.Black);

            Server = new TcpServer()
            {
                IpFiltering = IpFiltering,
                Port        = Configuration.Port
            };

            Server.InitServer();

            // Delegate
            SendGameServerPacket = SendGameServerData;

            WriteLog(LogType.System, "Login Server started", LogColor.Green);
        }
        public void InitServer()
        {
            Configuration.Open();
            Configuration.GetGeneralConfig();
            Configuration.GetDatabaseConfig();
            Configuration.Close();

            Configuration.ShowConfigInLog();
            Configuration.CheckDatabaseConnection();

            // Cria a instância e registra o delegate.
            DeleteRequest = new CharacterDeleteRequest();
            DeleteRequest.DeleteCharacter += DeleteCharacter;

            IpBlockList.Initialize();

            IpFiltering = new IpFiltering()
            {
                CheckAccessTime  = Configuration.CheckAccessTime,
                IpLifetime       = Configuration.IpLifetime,
                IpMaxAccessCount = Configuration.IpMaxAccessCount,
                IpMaxAttempt     = Configuration.IpMaxAttempt
            };

            WriteLog(LogType.System, "Initializing scripts", LogColor.Blue);
            var lua = new LuaScript();

            lua.InitializeScript();

            WriteLog(LogType.System, "Initializing prohibited names", LogColor.Blue);
            lua.LoadProhibitedNames();

            WriteLog(LogType.System, "Initializing character config", LogColor.Blue);
            lua.LoadCharacterConfiguration();
            Configuration.ShowCharacterConfigInLog();

            WriteLog(LogType.System, "Initializing game config", LogColor.Blue);
            lua.LoadGameConfiguration();

            WriteLog(LogType.System, "Initializing classes", LogColor.Blue);
            lua.LoadClasses();

            DataManagement.InitializeData();

            WriteLog(LogType.System, "Initializing map instances", LogColor.Blue);
            InitializeMaps();

            OpCode.Initialize();

            Login = new TcpLogin()
            {
                Port = Configuration.LoginPort
            };

            Login.InitServer();

            WriteLog(LogType.System, "Waiting for Login Server conenction", LogColor.Black);

            Server = new TcpServer()
            {
                Port        = Configuration.Port,
                IpFiltering = IpFiltering
            };

            Server.InitServer();
            WriteLog(LogType.System, "Game Server started", LogColor.Green);

            Initialized = true;
        }