Exemple #1
0
        public static void CreateRoom(Packet packet, Player player)
        {
            PVPRoom newRoom = new PVPRoom();

            newRoom.Name = packet.ReadString(40);
            newRoom.Password = packet.ReadString(10);
            ushort Info = packet.ReadUShort();
            newRoom.Map = packet.ReadUShort();
            newRoom.Observer = packet.ReadByte() != 0;

            // HasPassword is [((Info >> 0) & 0x01) != 0]
            newRoom.Mode = (RoomMode)((Info >> 1) & 0x1F);
            newRoom.MaxParticipant = (byte)((Info >> 6) & 0x0F);
            newRoom.Time = (byte)((Info >> 10) & 0x1F);
            newRoom.Item = ((Info >> 15) & 0x01) != 0;

            newRoom.ID = NextID;

            newRoom.AddPlayer(player);
            player.CharData.PVPRoom = newRoom;
            PVP.RemovePlayer(player);

            AddRoom(newRoom);

            #region Response
            Packet Response = new Packet(0x0809);
            Response.WriteByte(1);
            Response.WriteUShort((ushort)newRoom.ID);
            player.Sock.Send(Response);
            #endregion
        }
Exemple #2
0
        public static void RemoveRoom(PVPRoom room)
        {
            #region Packet
            foreach (Player x in Players)
            {
                Packet Others = new Packet(0x0811);
                Others.WriteUInt(room.ID);
                x.Sock.Send(Others);
            }
            #endregion

            Rooms.Remove(room);
        }
Exemple #3
0
        public static void AddRoom(PVPRoom room)
        {
            Rooms.Add(room);

            #region Packet
            foreach (Player x in Players)
            {
                ushort OthersInfo = (ushort)((room.Password == "" ? 0 : 1) +
                    ((int)room.Mode << 1) +
                    (room.Players.Count << 7) +
                    (room.MaxParticipant << 11) +
                    ((room.isInGame ? 1 : 0) << 15));

                Packet Others = new Packet(0x0810);
                Others.WriteUInt(room.ID);
                Others.WriteString(room.Name, 40);
                Others.WriteUShort(OthersInfo);
                x.Sock.Send(Others);
            }
            #endregion
        }