Example #1
0
        public bool RemovePlayer(Account p)
        {
            Channel ch = ServersManager.GetChannel(channelId);

            if (ch == null)
            {
                return(false);
            }
            BaseRemovePlayer(p);
            if (GetCountPlayers() == 0)
            {
                ch.RemoveMatch(matchId);
            }
            else
            {
                if (p.matchSlot == leader)
                {
                    SetNewLeader(-1, -1);
                }
                using (CLAN_WAR_REGIST_MERCENARY_PAK packet = new CLAN_WAR_REGIST_MERCENARY_PAK(this))
                {
                    SendPacketToPlayers(packet);
                }
            }
            p.matchSlot = -1;
            p.match     = null;
            return(true);
        }
Example #2
0
        public bool RemovePlayer(Account player)
        {
            bool result = false;

            try
            {
                player.channelId = -1;
                if (player.session != null)
                {
                    lock (players)
                    {
                        result = players.Remove(player.session);
                    }
                    if (result)
                    {
                        ServersManager.UpdateServerPlayers();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            return(result);
        }
Example #3
0
        public override void Close(int time = 0, bool kicked = false)
        {
            if (ConnectionIsClosed)
            {
                return;
            }
            ConnectionIsClosed = true;
            try
            {
                FirewallSecurity.RemoveRuleUdp(GetIPAddress(), SessionPort);
                GameManager.RemoveSession(this);
                if (SessionPlayer != null)
                {
                    Channel channel = SessionPlayer.GetChannel();
                    Room    room    = SessionPlayer.room;
                    Match   match   = SessionPlayer.match;
                    SessionPlayer.SetOnlineStatus(false);
                    if (room != null)
                    {
                        room.RemovePlayer(SessionPlayer, false, kicked ? 1 : 0);
                    }
                    if (match != null)
                    {
                        match.RemovePlayer(SessionPlayer);
                    }
                    if (channel != null)
                    {
                        channel.RemovePlayer(SessionPlayer);
                    }

                    SessionPlayer.status.ResetData(SessionPlayer.playerId);

                    SessionPlayer.SyncPlayerToFriends(false);
                    SessionPlayer.SyncPlayerToClanMembers();

                    ApiManager.SendPacketToAllClients(new API_USER_DISCONNECT_ACK(SessionPlayer, 0));
                    ApiManager.SendPacketToAllClients(new API_SERVER_INFO_ACK());

                    SessionPlayer.GameClear();
                    SessionPlayer.UpdateCacheInfo();
                    SessionPlayer = null;
                }
                if (SessionSocket != null)
                {
                    SessionSocket.Close(time);
                    Thread.Sleep(time);
                }
                FirewallSecurity.RemoveRuleTcp(GetIPAddress());
                Dispose();
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            ServersManager.UpdateServerPlayers(); //Auth
        }
Example #4
0
        public override void Close(int time = 0, bool destroy = true)
        {
            if (ConnectionIsClosed)
            {
                return;
            }
            ConnectionIsClosed = true;
            try
            {
                AuthManager.RemoveSession(this);
                if (destroy)
                {
                    if (SessionPlayer != null)
                    {
                        SessionPlayer.SetOnlineStatus(false);
                        SessionPlayer.status.ResetData(SessionPlayer.playerId);

                        SessionPlayer.SyncPlayerToFriends(false);
                        SessionPlayer.SyncPlayerToClanMembers();

                        ApiManager.SendPacketToAllClients(new API_SERVER_INFO_ACK());

                        SessionPlayer.GameClear();
                        SessionPlayer.UpdateCacheInfo();
                        SessionPlayer = null;
                    }
                    if (SessionSocket != null)
                    {
                        SessionSocket.Close(time);
                        Thread.Sleep(time);
                        FirewallSecurity.RemoveRuleTcp(GetIPAddress());
                    }
                    Dispose();
                }
                else if (SessionPlayer != null)
                {
                    SessionPlayer.client = null;
                    SessionPlayer.UpdateCacheInfo();
                    SessionPlayer = null;
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            ServersManager.UpdateServerPlayers();
        }
Example #5
0
 public bool AddPlayer(PlayerSession playerSession)
 {
     lock (players)
     {
         try
         {
             if (!players.Contains(playerSession))
             {
                 players.Add(playerSession);
                 ServersManager.UpdateServerPlayers();
                 return(true);
             }
         }
         catch (Exception ex)
         {
             Logger.Exception(ex);
         }
     }
     return(false);
 }
Example #6
0
        private static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomainOnUnhandledException);
            Console.CancelKeyPress += new ConsoleCancelEventHandler(CancelKeyPressEvent);
            try
            {
                //if (!IsAdministrator() || Console.NumberLock || Console.CapsLock)
                //{
                //    Environment.Exit(Environment.ExitCode);
                //    return;
                //}
                Console.SetWindowSize(125, 30);
                Console.CursorVisible        = false;
                Console.TreatControlCAsInput = false; //true=Entrada de combinação de tecla comum. false=Interrupção pelo sistema.
                Console.Title = "</> BR.UZ </>";
                Process ProcessApplication = Process.GetCurrentProcess();
                if (mutex.WaitOne(TimeSpan.Zero, true))
                {
                    try
                    {
                        DateTime LiveDate         = GetDate();
                        bool     IsInvalidLicense = LiveDate == new DateTime() || long.Parse(LiveDate.ToString("yyMMddHHmmss")) >= 210620000000;
                        if (IsInvalidLicense)
                        {
                            Environment.Exit(Environment.ExitCode);
                            return;
                        }
                        Settings.Load();
                        Logger.Start();
                        Debugger.ShowLogo();

                        SQLManager.Load();
                        ServerBlockManager.Load();
                        EventLoader.LoadAll();
                        MissionsXML.Load();
                        ClanManager.Load();

                        ShopManager.Load();
                        DefaultInventoryManager.Load();
                        ServersManager.Load();
                        TitlesManager.Load();
                        MissionCardXML.LoadBasicCards();
                        RankManager.Load();
                        MapsXML.Load();
                        ClanRankXML.Load();
                        MissionAwards.Load();
                        TournamentRulesManager.Load();
                        RandomBoxXML.LoadBoxes();
                        CupomEffectManager.Load();
                        PackageDataManager.Load();
                        StringFilter.Load();
                        AddressFilter.Load();

                        //BATTLE
                        HalfUtils.Load();
                        WeaponsXML.Load();
                        CharaXML.Load();
                        MappingXML.Load();

                        FirewallSecurity.LoadInstances(ProcessApplication.ProcessName, Settings.SessionsBattle);
                        FirewallSecurity.CreateRuleAllow(FirewallSecurity.FirewallRuleNameApiTCP, "127.0.0.1/255.255.255.255", Settings.PortApi, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP);   //Regra de permissão de acesso a especificos especificos endereços de ip na porta do Api.
                        FirewallSecurity.CreateRuleAllow(FirewallSecurity.FirewallRuleNameAuthTCP, "", Settings.PortAuth, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP);                          //Regra de permissão de acesso a todos endereços de ip na porta do Auth.
                        FirewallSecurity.CreateRuleAllow(FirewallSecurity.FirewallRuleNameGameTCP, "127.0.0.1/255.255.255.255", Settings.PortGame, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP); //Regra de permissão de acesso a todos endereços de ip na porta do Game que passaram na autenticação.
                        for (int i = 0; i < Settings.SessionsBattle; i++)
                        {
                            FirewallSecurity.CreateRuleAllow(FirewallSecurity.FirewallRuleNameBattleUDP[i], "127.0.0.1/255.255.255.255", Settings.PortBattle + i, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP); //Regra de permissão de acesso a todos endereços de ip na porta do Battle que passaram na autenticação e no Game.
                        }
                        Utilities.ExecuteQuery($"UPDATE accounts SET online='{false}'");                                                                                                                       //Seta o online de todas as contas como false

                        AuthManager.Start(Settings.IPInternal, Settings.PortAuth);
                        GameManager.Start(Settings.IPInternal, Settings.PortGame);
                        BattleManager.Start(Settings.IPInternal, Settings.PortBattle, Settings.SessionsBattle);
                        ApiManager.Start(Settings.IPInternal, Settings.PortApi);

                        //new Thread(CodeInDevelopment).Start();

                        if (Logger.Problem)
                        {
                            Logger.Red(" [Application] Startup failed.");
                        }
                        else
                        {
                            Logger.White($" [Application] Date time of server: {StartDate = DateTime.Now}");
                            Logger.Success(" [Application] Loaded all components.");
                            new Thread(new ThreadStart(TitleInfo)).Start();
                        }
                        ProcessApplication.WaitForExit();
                    }
                    finally
                    {
                        mutex.ReleaseMutex();
                    }
                }
                else
                {
                    MessageBox.Show("Console Application is already running.", ProcessApplication.ProcessName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(" FATAL ERROR: " + ex);
                Console.ReadKey();
            }
        }