Пример #1
0
 private byte[] GetRoomListData(Account player, ref int count, List <Room> list)
 {
     using (PacketWriter send = new PacketWriter())
     {
         for (int i = player.lastRoomPage * 15; i < list.Count; i++)
         {
             Room room = list[i];
             if (MapsXML.CheckId(room.mapId))
             {
                 byte restrictions = 0;
                 send.WriteD(room.roomId);
                 if (room.KickedPlayersVote.Contains(player.playerId))
                 {
                     send.WriteS("[Batalha inacessível]", 23);
                 }
                 else
                 {
                     send.WriteS(room.roomName, 23);
                 }
                 send.WriteH((ushort)room.mapId);
                 send.WriteC(room.stage4vs4);
                 send.WriteC((byte)room.mode);
                 send.WriteC((byte)room.state);
                 send.WriteC(room.GetAllPlayersCount());
                 send.WriteC(room.GetSlotCount());
                 send.WriteC(room.ping);
                 send.WriteC(room.weaponsFlag);
                 if (room.randomMap > 0)
                 {
                     restrictions += 2;
                 }
                 if (room.password.Length > 0)
                 {
                     restrictions += 4;
                 }
                 if (room.limit > 0 && room.state > RoomStateEnum.Ready)
                 {
                     restrictions += 128;
                 }
                 send.WriteC(restrictions);
                 send.WriteC((byte)room.modeSpecial);
             }
             if (count++ == 15)
             {
                 break;
             }
         }
         return(send.memorystream.ToArray());
     }
 }
Пример #2
0
 public override void RunImplement()
 {
     try
     {
         string log = $"roomId: {roomId} " +
                      $"roomName: {roomName} " +
                      $"mapId: {mapId} " +
                      $"stage4vs4: {stage4vs4} " +
                      $"stageType: {stageType} " +
                      $"state: {state} " +
                      $"players: {players} " +
                      $"slots: {slots} " +
                      $"ping: {ping} " +
                      $"weaponsFlag: {weaponsFlag} " +
                      $"randomMap: {randomMap} " +
                      $"modeSpecial: {modeSpecial} " +
                      $"leaderName: {leaderName} " +
                      $"killTime: {killTime} " +
                      $"limit: {limit} " +
                      $"seeConf: {seeConf} " +
                      $"balancing: {balancing} " +
                      $"aiCount: {aiCount} " +
                      $"aiLevel: {aiLevel}";
         Logger.DebugPacket(GetType().Name, log);
         //if (roomId >= 0 && roomId <= Settings.MaxRoomsPerChannel && roomName.Length > 0 && stage4vs4 >= 0 && stage4vs4 <= 1 && stageType >= RoomTypeEnum.Tutorial && stageType <= RoomTypeEnum.Escort && leaderName.Length > Settings.NickMinLength && limit >= 0 && limit <= 1 && balancing >= 0 && balancing <= 2)
         //{
         //}
         Logger.DebugPacket(GetType().Name, $"RoomId: {roomId} RoomName: {roomName} MapId: {mapId} Stage4vs4: {stage4vs4} StageType: {stageType} State: {state} Players: {players} Slots: {slots} Ping: {ping} WeaponsFlag: {weaponsFlag} RandomMap: {randomMap} ModeSpecial: {modeSpecial} LeaderName: {leaderName} KillTime: {killTime} Limit: {limit} SeeConf: {seeConf} Balancing: {balancing} AiCount: {aiCount} AiLevel: {aiLevel}");
         Account player = client.SessionPlayer;
         Room    room   = player != null ? player.room : null;
         if (leaderName != player.nickname)
         {
             Logger.Warning($" [PROTOCOL_ROOM_CHANGE_INFO_REQ] Nome do lider incorreto! Leader: {leaderName} Player: {player.nickname}");
         }
         if (room.roomId != roomId)
         {
             Logger.Warning($" [PROTOCOL_ROOM_CHANGE_INFO_REQ] Id da sala incorreto! RoomId: {roomId} SalaId: {room.roomId}");
         }
         if (room != null && room.roomId == roomId && leaderName == player.nickname && room.leaderSlot == player.slotId && room.state == state && room.state == RoomStateEnum.Ready && MapsXML.CheckId(mapId))
         {
             string oldName = room.roomName;
             room.roomName    = roomName;
             room.mapId       = mapId;
             room.stage4vs4   = stage4vs4;
             room.ping        = ping;
             room.randomMap   = randomMap;
             room.modeSpecial = modeSpecial;
             room.leaderName  = leaderName;
             room.killtime    = killTime;
             room.limit       = limit;
             room.seeConf     = seeConf;
             room.balancing   = (BalancingTeamEnum)balancing;
             room.aiCount     = aiCount;
             room.aiLevel     = aiLevel;
             if (stageType != room.mode || weaponsFlag != room.weaponsFlag || oldName != roomName && TournamentRulesManager.CheckRoomRule(oldName.ToUpper()) || TournamentRulesManager.CheckRoomRule(roomName.ToUpper()))
             {
                 room.mode = stageType;
                 if (!room.isModePorrada)
                 {
                     room.weaponsFlag = weaponsFlag;
                 }
                 int count = 0;
                 for (int i = 0; i < 16; i++)
                 {
                     Slot slot = room.slots[i];
                     if (slot.state == SlotStateEnum.READY)
                     {
                         slot.state = SlotStateEnum.NORMAL;
                         count++;
                     }
                 }
                 if (count > 0)
                 {
                     room.UpdateSlotsInfo();
                 }
             }
             room.UpdateRoomInfo();
         }
         else
         {
             Logger.Warning($"[{GetType().Name}] NÃO FOI POSSIVEL ALTERAR AS INFORMAÇÕES DA SALA [!] RoomId ({room.roomId}/{roomId}) LeaderName ({leaderName}/{player.nickname}) LeaderSlot ({room.leaderSlot}/{player.slotId}) RoomState ({room.state}/{state})");
         }
     }
     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);
     }
 }
Пример #4
0
 public override void RunImplement()
 {
     try
     {
         Logger.DebugPacket(GetType().Name, $"RoomName: {roomName} MapId: {mapId} Stage4vs4: {stage4vs4} StageType: {stageType} Ping: {ping} WeaponsFlag: {weaponsFlag} RandomMap: {randomMap} ModeSpecial: {modeSpecial} AiCount: {aiCount} AiLevel: {aiLevel} roomId: {roomId} state: {state} players: {players} slots: {slots}");
         Account player = client.SessionPlayer;
         Room    room   = player != null ? player.room : null;
         if (room == null || room.state != state || room.state != RoomStateEnum.Ready || room.leaderSlot != player.slotId || !MapsXML.CheckId(mapId))
         {
             return;
         }
         string oldName = room.roomName;
         room.roomName    = roomName;
         room.mapId       = mapId;
         room.stage4vs4   = stage4vs4;
         room.ping        = ping;
         room.randomMap   = randomMap;
         room.modeSpecial = modeSpecial;
         room.aiCount     = aiCount;
         room.aiLevel     = aiLevel;
         if (stageType != room.mode || weaponsFlag != room.weaponsFlag || oldName != roomName && TournamentRulesManager.CheckRoomRule(oldName.ToUpper()) || TournamentRulesManager.CheckRoomRule(roomName.ToUpper()))
         {
             room.mode = stageType;
             if (!room.isModePorrada)
             {
                 room.weaponsFlag = weaponsFlag;
             }
             int count = 0;
             for (int i = 0; i < 16; i++)
             {
                 Slot slot = room.slots[i];
                 if (slot.state == SlotStateEnum.READY)
                 {
                     slot.state = SlotStateEnum.NORMAL;
                     count++;
                 }
             }
             if (count > 0)
             {
                 room.UpdateSlotsInfo();
             }
         }
         room.UpdateRoomInfo();
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }