コード例 #1
0
ファイル: Clan.cs プロジェクト: Theoretical/bunnyemu
        public static void CancelClanWarRequest(Client client, PendingClanWarRequest clan, Timer timer)
        {
            lock (Globals.PendingClanWar)
                try
                {
                    Globals.PendingClanWar.Remove(clan);
                    timer.Enabled = false;

                }
                catch (ObjectDisposedException)
                {
                }
        }
コード例 #2
0
ファイル: Clan.cs プロジェクト: Theoretical/bunnyemu
        public static void ProcessRequestProposal(Client client, PacketReader packetReader)
        {
            var uid = packetReader.ReadMuid();
            var mode = packetReader.ReadInt32();
            var request = packetReader.ReadInt32();
            var memberCount = packetReader.ReadInt32();
            var totalSize = packetReader.ReadInt32();
            var blobSize = packetReader.ReadInt32();
            var blobCount = packetReader.ReadInt32();
            List<byte[]> blob = new List<byte[]>();

            if (memberCount == blobCount)
            {
                for (int i = 0; i < blobCount; ++i)
                {
                    var temp = new byte[blobSize];
                    packetReader.Read(temp, 0, blobSize);
                    blob.Add(temp);
                }
            }
            else
            {
                client.Disconnect();
                return;
            }

            List<Client> requests = new List<Client>();

            foreach (byte[] b in blob)
            {
                string s = System.Text.ASCIIEncoding.ASCII.GetString(b);
                s = s.Substring(0, s.IndexOf('\0'));
                requests.Add(TcpServer.GetClientFromName(s));
            }

            if (requests.FindAll(c => c.GetCharacter().ClanId == client.GetCharacter().ClanId).Count == memberCount)
            {
                List<Pair<Client, bool>> list = new List<Pair<Client, bool>>();

                foreach (Client c in requests)
                {
                    list.Add(new Pair<Client, bool>(c, false));
                }
                list.Add(new Pair<Client, bool>(client, true));

                ClanPackets.AskAgreement(requests, client, mode, request);
                ClanPackets.ResponseProposal(client, 0, mode, request);

                PendingClanWarRequest pc = new PendingClanWarRequest();
                pc.RequestId = request;
                pc.Players = list;
                pc.ClanName = client.GetCharacter().ClanName;
                pc.Requester = client;
                pc.RequestMode = mode;

                lock(Globals.PendingClanWar)
                    Globals.PendingClanWar.Add(pc);

                var responsetimer = new Timer(30000);
                responsetimer.Elapsed += (s, o) => CancelClanWarRequest(client, pc, responsetimer);
                responsetimer.Start();
            }
        }