Beispiel #1
0
        public static void CancelRequest(Client client, PendingClan clan, Timer timer)
        {
            lock (Globals.PendingClans)
                try
                {
                    Globals.PendingClans.Remove(clan);
                    timer.Enabled = false;

                }
                catch (ObjectDisposedException)
                {
                }

            ClanPackets.ResponseCreateClan(client, Results.ClanCannotBeCreated, clan.RequestId);
        }
Beispiel #2
0
        public static void ProcessCreateClan(Client client, PacketReader packetReader)
        {
            var masterId = packetReader.ReadMuid();
            var reqeuest = packetReader.ReadInt32();
            var clanName = packetReader.ReadString();
            var member1 = packetReader.ReadString();
            var member2 = packetReader.ReadString();
            var member3 = packetReader.ReadString();
            var member4 = packetReader.ReadString();

            var members = new List<Client>();
            members.Add(TcpServer.GetClientFromName(member1));
            members.Add(TcpServer.GetClientFromName(member2));
            members.Add(TcpServer.GetClientFromName(member3));
            members.Add(TcpServer.GetClientFromName(member4));

            if (!Globals.AcceptedString.IsMatch(clanName))
            {
                return;
            }

            if (Globals.GunzDatabase.ClanExists(clanName))
            {
                ClanPackets.ResponseCreateClan(client, Results.ClanNameInUse, reqeuest);
                return;
            }

            foreach (var member in members)
            {
                if (member == null || Globals.GunzDatabase.IsInClan(member))
                {
                    ClanPackets.ResponseCreateClan(client, Results.ClanUserAlreadyInAClan, reqeuest);
                    return;
                }
            }

            var pendingClan = new PendingClan();
            pendingClan.ClanMaster = client;
            pendingClan.ClanName = clanName;
            pendingClan.RequestId = reqeuest;
            pendingClan.Member1 = new Pair<Client, bool>(members[0], false);
            pendingClan.Member2 = new Pair<Client, bool>(members[1], false);
            pendingClan.Member3 = new Pair<Client, bool>(members[2], false);
            pendingClan.Member4 = new Pair<Client, bool>(members[3], false);

            lock (Globals.PendingClans)
                Globals.PendingClans.Add(pendingClan);

            ClanPackets.ResponseCreateClan(client, Results.Accepted, reqeuest);
            ClanPackets.AskAgreement(members, reqeuest, clanName, client.GetMuid(), client.GetCharacter().Name);

            var responsetimer = new Timer(30000);
            responsetimer.Elapsed += (s, o) => CancelRequest(client, pendingClan, responsetimer);
            responsetimer.Start();
        }
Beispiel #3
0
        public static void ResponseAagreedCreateClan(PendingClan pendingClan)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseAgreedCreateClan, CryptFlags.Encrypt))
            {
                packet.Write(0);

                pendingClan.ClanMaster.Send(packet);
                pendingClan.Member1.First.Send(packet);
                pendingClan.Member2.First.Send(packet);
                pendingClan.Member3.First.Send(packet);
                pendingClan.Member4.First.Send(packet);
            }
        }