Beispiel #1
0
        public static void ResponseChannelJoinFromName(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var type = pPacket.ReadInt32();
            var name = pPacket.ReadString();

            if (!Enum.IsDefined(typeof(MMatchChannelType), (byte)type))
            {
                pClient.Disconnect();
                return;
            }

            MMatchChannel channel = Program.mChannels.Find(c => c.nChannelType == (MMatchChannelType)type && c.szName.Equals(name));
            if (channel == null)
            {
                channel = new MMatchChannel();
                channel.szName = name;
                channel.lClients = new List<Client>();
                channel.nChannelRule = MMatchChannelRule.Elite;
                channel.nChannelType = (MMatchChannelType)type;
                channel.nMaxLevel = 100;
                channel.nMinLevel = 0;
                channel.nMaxUsers = 200;
                channel.uidChannel = (UInt64)Program.mChannels.Count;
                lock (Program.mChannels)
                    Program.mChannels.Add(channel);
            }
            ChannelMgr.Join(pClient, channel);
        }
Beispiel #2
0
 private static void LoadChannels()
 {
     XmlReader reader = new XmlTextReader("channel.xml");
     while (reader.Read())
     {
         switch (reader.Name)
         {
             case "CHANNEL":
                 MMatchChannel channel = new MMatchChannel();
                 channel.szName = reader.GetAttribute("name");
                 if (!Int32.TryParse(reader.GetAttribute("levelmin"), out channel.nMinLevel))
                     channel.nMinLevel = 0;
                 channel.nMaxUsers = Int32.Parse(reader.GetAttribute("maxplayers"));
                 channel.uidChannel = Convert.ToUInt64(mChannels.Count);
                 channel.nChannelType = MMatchChannelType.General;
                 switch (reader.GetAttribute("rule"))
                 {
                     case "elite":
                         channel.nChannelRule = MMatchChannelRule.Elite;
                         break;
                 }
                 mChannels.Add(channel);
                 break;
         }
     }
 }
Beispiel #3
0
        public static void Join(Client pClient, MMatchChannel pChannel)
        {
            Leave(pClient);
            lock (pChannel.lClients)
                pChannel.lClients.Add(pClient);

            pClient.mPlace = MMatchPlace.Lobby;
            pClient.mChannel = pChannel;

            PacketWriter pPacket = new PacketWriter(Operation.ChannelResponseJoin, CryptFlags.Encrypt);
            pPacket.Write(pChannel.uidChannel);
            pPacket.Write((Int32)pChannel.nChannelType);
            pPacket.Write(pChannel.szName);
            pPacket.Write(true);
            pClient.Send(pPacket);

            pPacket = new PacketWriter(Operation.MatchResponseRuleset, CryptFlags.Encrypt);
            pPacket.Write(pChannel.uidChannel);
            pPacket.Write(pChannel.nChannelRule.ToString().ToLower());
            pClient.Send(pPacket);

            foreach (Client c in pChannel.lClients)
            {
                PlayerList(c);
            }
        }