Ejemplo n.º 1
0
        public void Close(int time, bool kicked = false)
        {
            if (!closed)
            {
                try
                {
                    closed = true;
                    GameManager.RemoveSocket(this);
                    Account p = _player;
                    if (player_id > 0 && p != null)
                    {
                        Channel ch    = p.getChannel();
                        Room    room  = p._room;
                        Match   match = p._match;
                        p.setOnlineStatus(false);
                        if (room != null)
                        {
                            room.RemovePlayer(p, false, kicked ? 1 : 0);
                        }
                        if (match != null)
                        {
                            match.RemovePlayer(p);
                        }
                        if (ch != null)
                        {
                            ch.RemovePlayer(p);
                        }
                        p._status.ResetData(player_id);

                        AllUtils.syncPlayerToFriends(p, false);
                        AllUtils.syncPlayerToClanMembers(p);

                        p.SimpleClear();
                        p.updateCacheInfo();
                        _player = null;
                    }
                    player_id = 0;
                }
                catch (Exception ex)
                {
                    SaveLog.fatal("Error by: " + player_id + "\n" + ex.ToString());
                    Printf.b_danger("[GameClient.Close] Erro fatal!");
                }
            }
            if (_client != null)
            {
                _client.Close(time);
            }
            Dispose();
        }
Ejemplo n.º 2
0
        public override void run()
        {
            try
            {
                if (_client == null)
                {
                    return;
                }
                Account player = _client._player;
                if (player == null)
                {
                    return;
                }
                player.LastLobbyEnter = DateTime.Now;
                if (player.channelId >= 0)
                {
                    Channel ch = player.getChannel();
                    if (ch != null)
                    {
                        ch.AddPlayer(player.Session);
                    }
                }
                Room room = player._room;
                if (room != null)
                {
                    if (player._slotId >= 0 && (int)room._state >= 2 && (int)room._slots[player._slotId].state >= 9)
                    {
                        goto JumpToPacket;
                    }
                    else
                    {
                        room.RemovePlayer(player, false);
                    }
                }
                AllUtils.syncPlayerToFriends(player, false);
                AllUtils.syncPlayerToClanMembers(player);
                AllUtils.GetXmasReward(player);
JumpToPacket:
                _client.SendPacket(new LOBBY_ENTER_PAK());
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[LOBBY_ENTER_REC.run] Erro fatal!");
            }
        }
Ejemplo n.º 3
0
 public bool addPlayer(Account player)
 {
     lock (_slots)
         for (int i = 0; i < formação; i++)
         {
             SLOT_MATCH slot = _slots[i];
             if (slot._playerId == 0 && (int)slot.state == 0)
             {
                 slot._playerId   = player.player_id;
                 slot.state       = SlotMatchState.Normal;
                 player._match    = this;
                 player.matchSlot = i;
                 player._status.updateClanMatch((byte)friendId);
                 AllUtils.syncPlayerToClanMembers(player);
                 return(true);
             }
         }
     return(false);
 }
Ejemplo n.º 4
0
        public override void run()
        {
            try
            {
                if (this._client == null)
                {
                    return;
                }
                Account player = this._client._player;
                if (player == null)
                {
                    return;
                }
                player.LastLobbyEnter = DateTime.Now;
                if (player.channelId >= 0)
                {
                    player.getChannel().AddPlayer(player.Session);
                }
                Room room = player._room;
                if (room != null)
                {
                    if (player._slotId < 0 || room._state < RoomState.Loading || room._slots[player._slotId].state < SLOT_STATE.LOAD)
                    {
                        room.RemovePlayer(player, false, 0);
                    }
                    else
                    {
                        goto label_9;
                    }
                }
                AllUtils.syncPlayerToFriends(player, false);
                AllUtils.syncPlayerToClanMembers(player);
                AllUtils.GetXmasReward(player);
label_9:
                this._client.SendPacket((SendPacket) new LOBBY_ENTER_PAK());
            }
            catch (Exception ex)
            {
                Logger.warning("[LOBBY_ENTER_REC] " + ex.ToString());
            }
        }
Ejemplo n.º 5
0
 public bool addPlayer(Account player)
 {
     lock (this._slots)
     {
         for (int index = 0; index < this.formação; ++index)
         {
             SLOT_MATCH slot = this._slots[index];
             if (slot._playerId == 0L && slot.state == SlotMatchState.Empty)
             {
                 slot._playerId   = player.player_id;
                 slot.state       = SlotMatchState.Normal;
                 player._match    = this;
                 player.matchSlot = index;
                 player._status.updateClanMatch((byte)this.friendId);
                 AllUtils.syncPlayerToClanMembers(player);
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 6
0
 public override void run()
 {
     try
     {
         if (_client == null || _client._player == null)
         {
             return;
         }
         Account player  = _client._player;
         Channel channel = player.getChannel();
         if (player._room != null || player._match != null)
         {
             return;
         }
         if (channel == null || player.Session == null || !channel.RemovePlayer(player))
         {
             erro = 0x80000000;
         }
         _client.SendPacket(new LOBBY_LEAVE_PAK(erro));
         if (erro == 0)
         {
             player.ResetPages();
             player._status.updateChannel(255);
             AllUtils.syncPlayerToFriends(player, false);
             AllUtils.syncPlayerToClanMembers(player);
         }
         else
         {
             _client.Close(1000);
         }
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[LOBBY_LEAVE_REC.AddItems] Erro fatal!");
         _client.SendPacket(new LOBBY_LEAVE_PAK(0x80000000));
         _client.Close(1000);
     }
 }
Ejemplo n.º 7
0
 public override void run()
 {
     try
     {
         if (this._client == null || this._client._player == null)
         {
             return;
         }
         Account player  = this._client._player;
         Channel channel = player.getChannel();
         if (player._room != null || player._match != null)
         {
             return;
         }
         if (channel == null || player.Session == null || !channel.RemovePlayer(player))
         {
             this.erro = 2147483648U;
         }
         this._client.SendPacket((SendPacket) new LOBBY_LEAVE_PAK(this.erro));
         if (this.erro == 0U)
         {
             player.ResetPages();
             player._status.updateChannel(byte.MaxValue);
             AllUtils.syncPlayerToFriends(player, false);
             AllUtils.syncPlayerToClanMembers(player);
         }
         else
         {
             this._client.Close(1000, false);
         }
     }
     catch (Exception ex)
     {
         Logger.info("LOBBY_LEAVE_REC: " + ex.ToString());
         this._client.SendPacket((SendPacket) new LOBBY_LEAVE_PAK(2147483648U));
         this._client.Close(1000, false);
     }
 }
Ejemplo n.º 8
0
 public void Close(int time, bool kicked = false)
 {
     if (!this.closed)
     {
         try
         {
             this.closed = true;
             GameManager.RemoveSocket(this);
             Account player = this._player;
             if (this.player_id > 0L && player != null)
             {
                 Channel channel = player.getChannel();
                 Room    room    = player._room;
                 Match   match   = player._match;
                 player.setOnlineStatus(false);
                 room.RemovePlayer(player, false, kicked ? 1 : 0);
                 match.RemovePlayer(player);
                 channel.RemovePlayer(player);
                 player._status.ResetData(this.player_id);
                 AllUtils.syncPlayerToFriends(player, false);
                 AllUtils.syncPlayerToClanMembers(player);
                 player.SimpleClear();
                 player.updateCacheInfo();
                 this._player = (Account)null;
             }
             this.player_id = 0L;
         }
         catch (Exception ex)
         {
             Logger.warning("Error by: " + (object)this.player_id + "\n" + ex.ToString());
         }
     }
     if (this._client != null)
     {
         this._client.Close(time);
     }
     this.Dispose();
 }
Ejemplo n.º 9
0
 public override void run()
 {
     try
     {
         Account p  = _client._player;
         Match   mt = p == null ? null : p._match;
         if (mt == null || !mt.RemovePlayer(p))
         {
             erro = 0x80000000;
         }
         _client.SendPacket(new CLAN_WAR_LEAVE_TEAM_PAK(erro));
         if (erro == 0)
         {
             p._status.updateClanMatch(255);
             AllUtils.syncPlayerToClanMembers(p);
         }
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[CLAN_WAR_LEAVE_TEAM_REC.run] Erro fatal!");
     }
 }
Ejemplo n.º 10
0
 public override void run()
 {
     try
     {
         Account player = this._client._player;
         Match   match  = player == null ? (Match)null : player._match;
         if (match == null || !match.RemovePlayer(player))
         {
             this.erro = 2147483648U;
         }
         this._client.SendPacket((SendPacket) new CLAN_WAR_LEAVE_TEAM_PAK(this.erro));
         if (this.erro != 0U)
         {
             return;
         }
         player._status.updateClanMatch(byte.MaxValue);
         AllUtils.syncPlayerToClanMembers(player);
     }
     catch (Exception ex)
     {
         Logger.info(ex.ToString());
     }
 }