示例#1
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || player.checkUserFriends)
         {
             return;
         }
         player.checkUserFriends = true;
         if (!player.checkSourceInfo || !player.checkUserInfo)
         {
             Logger.Attacks($" [Auth] (PROTOCOL_BASE_USER_FRIENDS_REQ) Connection destroyed on suspicion of modified client. IPAddress: {client.GetIPAddress()}");
             client.Close(0, true);
             return;
         }
         FirewallSecurity.AddRuleTcp(client.GetIPAddress());
         client.SendPacket(new PROTOCOL_BASE_EXIT_URL_ACK(Settings.ExitUrl));
         player.LoadPlayerFriends(false);
         player.UpdateCommunity(true);
         player.LoadPlayerConfigs();
         List <Friend> friends = player.friends.friendsCache;
         if (friends.Count > 0)
         {
             client.SendPacket(new PROTOCOL_BASE_USER_FRIENDS_ACK(friends));
         }
         List <Message> messages = player.GetMessages();
         if (messages.Count > 0)
         {
             player.RecicleMessages(messages);
             if (messages.Count > 0)
             {
                 byte pages = (byte)Math.Ceiling(messages.Count / 25d);
                 for (byte i = 0; i < pages; i++)
                 {
                     client.SendPacket(new PROTOCOL_BASE_USER_MESSAGES_ACK(i, messages));
                 }
             }
         }
         client.SendPacket(new PROTOCOL_BASE_USER_CONFIG_ACK(player.configs, player.nickname.Length == 0 || player.configs == null, 0));
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
示例#2
0
 public override void RunImplement()
 {
     try
     {
         Logger.DebugPacket(GetType().Name, $"objId: {objId}");
         Account player = client.SessionPlayer;
         Room    room   = player != null ? player.room : null;
         if (room == null || room.state < RoomStateEnum.Loading || !room.GetSlot(player.slotId, out Slot slot) || slot.state < SlotStateEnum.LOAD)
         {
             return;
         }
         bool isBotMode = room.IsBotMode();
         FreepassEffect(player, slot, room, isBotMode);
         if (room.vote.Timer != null && room.votekick != null && room.votekick.victimIdx == slot.Id)
         {
             room.vote.Timer = null;
             room.votekick   = null;
             room.SendPacketToPlayers(PackageDataManager.VOTEKICK_CANCEL_VOTE_PAK, SlotStateEnum.BATTLE, 0, slot.Id);
         }
         room.ResetSlotInfo(slot, true);
         int red13 = 0, blue13 = 0, red9 = 0, blue9 = 0;
         for (int i = 0; i < 16; i++)
         {
             Slot slotR = room.slots[i];
             if (slotR.state >= SlotStateEnum.LOAD)
             {
                 if (slotR.teamId == 0)
                 {
                     red9++;
                 }
                 else
                 {
                     blue9++;
                 }
                 if (slotR.state == SlotStateEnum.BATTLE)
                 {
                     if (slotR.teamId == 0)
                     {
                         red13++;
                     }
                     else
                     {
                         blue13++;
                     }
                 }
             }
         }
         if (slot.Id == room.leaderSlot)
         {
             if (isBotMode)
             {
                 if (red13 > 0 || blue13 > 0)
                 {
                     LeaveHostBOT_GiveBattle(room, player);
                 }
                 else
                 {
                     LeaveHostBOT_EndBattle(room, player);
                 }
             }
             else if ((room.state == RoomStateEnum.Battle && (red13 == 0 || blue13 == 0)) || (room.state <= RoomStateEnum.PreBattle && (red9 == 0 || blue9 == 0)))
             {
                 LeaveHostNoBOT_EndBattle(room, player, red13, blue13);
             }
             else
             {
                 LeaveHostNoBOT_GiveBattle(room, player);
             }
         }
         else if (!isBotMode)
         {
             if ((room.state == RoomStateEnum.Battle && (red13 == 0 || blue13 == 0)) || (room.state <= RoomStateEnum.PreBattle && (red9 == 0 || blue9 == 0)))
             {
                 LeavePlayerNoBOT_EndBattle(room, player, red13, blue13);
             }
             else
             {
                 LeavePlayer_QuitBattle(room, player);
             }
         }
         else
         {
             LeavePlayer_QuitBattle(room, player);
         }
         client.SendPacket(new PROTOCOL_BATTLE_LEAVEP2PSERVER_ACK(player, 0));
         FirewallSecurity.RemoveRuleUdp(client.GetIPAddress(), client.SessionPort);
         if (!isFinished && room.state == RoomStateEnum.Battle)
         {
             room.BattleEndRoundPlayersCount();
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
示例#3
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         Room    room   = player != null ? player.room : null;
         if (room == null)
         {
             Logger.Warning($" [Game] [{GetType().Name}] Room is null.");
             client.Close(0, false);
             return;
         }
         if (room.stage4vs4 != stage4vs4 || room.mode != roomType || room.mapId != mapId || !MapsXML.CheckId(mapId))
         {
             client.SendCompletePacket(PackageDataManager.PROTOCOL_SERVER_MESSAGE_KICK_BATTLE_PLAYER_0x8000100A_ACK);
             room.ChangeSlotState(player.slotId, SlotStateEnum.NORMAL, true);
             room.BattleEndPlayersCount(room.IsBotMode());
             return;
         }
         Slot slot = room.slots[player.slotId];
         if (!room.IsPreparing() || slot.state < SlotStateEnum.LOAD)
         {
             client.SendCompletePacket(PackageDataManager.PROTOCOL_BATTLE_STARTBATTLE_ACK);
             room.ChangeSlotState(slot, SlotStateEnum.NORMAL, true);
             room.BattleEndPlayersCount(room.IsBotMode());
             slot.StopTiming();
             return;
         }
         Account leader = room.GetLeader();
         if (leader == null)
         {
             client.SendCompletePacket(PackageDataManager.PROTOCOL_SERVER_MESSAGE_KICK_BATTLE_PLAYER_0x8000100B_ACK);
             client.SendPacket(new PROTOCOL_BATTLE_LEAVEP2PSERVER_ACK(player, 0));
             room.ChangeSlotState(slot, SlotStateEnum.NORMAL, true);
             room.BattleEndPlayersCount(room.IsBotMode());
             slot.StopTiming();
             return;
         }
         if (player.localIP == new byte[4] || player.localIP.Length == 0 || player.ipAddress.GetAddressBytes() == new byte[4] || player.ipAddress.GetAddressBytes().Length == 0)
         {
             client.SendCompletePacket(PackageDataManager.PROTOCOL_SERVER_MESSAGE_KICK_BATTLE_PLAYER_0x80001008_ACK);
             client.SendPacket(new PROTOCOL_BATTLE_LEAVEP2PSERVER_ACK(player, 0));
             room.ChangeSlotState(slot, SlotStateEnum.NORMAL, true);
             room.BattleEndPlayersCount(room.IsBotMode());
             slot.StopTiming();
             return;
         }
         client.SessionPort = room.sessionPort;
         FirewallSecurity.AddRuleUdp(client.GetIPAddress(), client.SessionPort);
         byte UdpType = (byte)Settings.UdpType;
         if (slot.Id == room.leaderSlot)
         {
             room.state = RoomStateEnum.PreBattle;
             room.UpdateRoomInfo();
             room.GenerateRoomSeed();
             //room.LoadHitParts();
         }
         room.ChangeSlotState(slot, SlotStateEnum.PRESTART, true);
         client.SendPacket(new PROTOCOL_BATTLE_PRESTARTBATTLE_ACK(player, leader, true, UdpType));
         if (slot.Id != room.leaderSlot)
         {
             leader.SendPacket(new PROTOCOL_BATTLE_PRESTARTBATTLE_ACK(player, leader, false, UdpType));
         }
         room.StartCounter(1, player, slot);
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }