Пример #1
0
        public static void SendAuctionListBidderItems(IPacketReceiver client, Auction[] auctions)
        {
            if (auctions == null || auctions.Length < 1)
            {
                return;
            }
            RealmPacketOut packet =
                new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_BIDDER_LIST_RESULT, 1024);

            packet.Write(auctions.Length);
            foreach (Auction auction in auctions)
            {
                BuildAuctionPacket(auction, packet);
            }
            packet.Write(auctions.Length);
            packet.Write(0);
            client.Send(packet, false);
            packet.Close();
        }
Пример #2
0
        public static void SendAuctionListBidderItems(IPacketReceiver client, Auction[] auctions)
        {
            if (auctions == null || auctions.Length < 1)
            {
                return;
            }

            //can not use "using" block if a ref parameter in there.
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_BIDDER_LIST_RESULT, 1024);

            packet.Write(auctions.Length);

            foreach (var auction in auctions)
            {
                BuildAuctionPacket(auction, packet);
            }
            packet.Write(auctions.Length);
            packet.Write(0);
            client.Send(packet, addEnd: false);
            packet.Close();
        }
Пример #3
0
        public void TestPacketHandling()
        {
            Assert.IsNotNull(m_chr);
            Assert.IsNotNull(RealmPacketMgr.Instance[RealmServerOpCode.SMSG_DBLOOKUP]);
            RealmPacketMgr.Instance[RealmServerOpCode.SMSG_DBLOOKUP].RequiresLogIn = false;

            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_DBLOOKUP);

            packet.Write(true);
            packet.Write("abc");
            packet.WriteUInt(345);
            packet.WriteByte(0xFF);

            var packets = receivedPackets;

            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            packet.Close();
            Assert.AreEqual(packets + 4, receivedPackets);
        }
Пример #4
0
        public void TestPacketSending()
        {
            Assert.IsNotNull(m_chr);
            Assert.IsNotNull(FakePacketMgr.Instance[RealmServerOpCode.CMSG_BOOTME]);
            FakePacketMgr.Instance[RealmServerOpCode.CMSG_BOOTME].RequiresLogIn = false;

            var packet = new RealmPacketOut(RealmServerOpCode.CMSG_BOOTME);

            packet.Write(true);
            packet.Write("abc");
            packet.WriteUInt(345);
            packet.WriteByte(0xFF);

            var packets = sentPackets;

            m_chr.FakeClient.SendAndWait(packet, false);
            m_chr.FakeClient.SendAndWait(packet, false);
            m_chr.FakeClient.SendAndWait(packet, false);
            m_chr.FakeClient.SendAndWait(packet, false);
            packet.Close();
            Assert.AreEqual(packets + 4, sentPackets);
        }
Пример #5
0
        public static void SendAuctionListItems(IPacketReceiver client, Auction[] auctions)
        {
            if (auctions == null || auctions.Length < 1)
            {
                return;
            }
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_RESULT, 7000);
            var count  = 0;

            packet.Write(auctions.Length);
            foreach (var auction in auctions)
            {
                if (BuildAuctionPacket(auction, packet))
                {
                    count++;
                }
            }
            //packet.InsertIntAt(count, 0, true);
            packet.Write(count);
            packet.Write(300);
            client.Send(packet, addEnd: false);
            packet.Close();
        }
Пример #6
0
        public static void SendAuctionListItems(IPacketReceiver client, Auction[] auctions)
        {
            if (auctions == null || auctions.Length < 1)
            {
                return;
            }
            RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_RESULT, 7000);
            int            num    = 0;

            packet.Write(auctions.Length);
            foreach (Auction auction in auctions)
            {
                if (BuildAuctionPacket(auction, packet))
                {
                    ++num;
                }
            }

            packet.Write(num);
            packet.Write(300);
            client.Send(packet, false);
            packet.Close();
        }
Пример #7
0
		public static void SendAuctionListItems(IPacketReceiver client, Auction[] auctions)
		{
			if (auctions == null || auctions.Length < 1)
				return;
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_RESULT, 7000);
            var count = 0;
            packet.Write(auctions.Length);
			foreach (var auction in auctions)
			{
				if(BuildAuctionPacket(auction, packet))
                    count++;
			}
            //packet.InsertIntAt(count, 0, true);
			packet.Write(count);
			packet.Write(300);
			client.Send(packet);
			packet.Close();

		}
Пример #8
0
		public static void SendAuctionListBidderItems(IPacketReceiver client, Auction[] auctions)
		{
			if (auctions == null || auctions.Length < 1)
				return;

			//can not use "using" block if a ref parameter in there.
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_BIDDER_LIST_RESULT, 1024);
			packet.Write(auctions.Length);

			foreach (var auction in auctions)
			{
				BuildAuctionPacket(auction, packet);
			}
			packet.Write(auctions.Length);
			packet.Write(0);
			client.Send(packet);
			packet.Close();
		}
Пример #9
0
        public void TestPacketSending()
        {
            Assert.IsNotNull(m_chr);
            Assert.IsNotNull(FakePacketMgr.Instance[RealmServerOpCode.CMSG_BOOTME]);
            FakePacketMgr.Instance[RealmServerOpCode.CMSG_BOOTME].RequiresLogIn = false;

            var packet = new RealmPacketOut(RealmServerOpCode.CMSG_BOOTME);
            packet.Write(true);
            packet.Write("abc");
            packet.WriteUInt(345);
            packet.WriteByte(0xFF);

            var packets = sentPackets;
            m_chr.FakeClient.SendAndWait(packet, false);
            m_chr.FakeClient.SendAndWait(packet, false);
            m_chr.FakeClient.SendAndWait(packet, false);
            m_chr.FakeClient.SendAndWait(packet, false);
            packet.Close();
            Assert.AreEqual(packets + 4, sentPackets);
        }
Пример #10
0
        public void TestPacketHandling()
        {
            Assert.IsNotNull(m_chr);
            Assert.IsNotNull(RealmPacketMgr.Instance[RealmServerOpCode.SMSG_DBLOOKUP]);
            RealmPacketMgr.Instance[RealmServerOpCode.SMSG_DBLOOKUP].RequiresLogIn = false;

            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_DBLOOKUP);
            packet.Write(true);
            packet.Write("abc");
            packet.WriteUInt(345);
            packet.WriteByte(0xFF);

            var packets = receivedPackets;
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            m_chr.FakeClient.ReceiveCMSG(packet, false, true);
            packet.Close();
            Assert.AreEqual(packets + 4, receivedPackets);
        }
Пример #11
0
        public static void SayYellEmote(this Character sender, ChatMsgType type, ChatLanguage language, string msg, float radius)
        {
            if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character))
            {
                return;
            }

            if (type != ChatMsgType.WhisperInform && msg.Length == 0)
            {
                return;
            }

            if (GlobalChat)
            {
                using (var packetOut = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, msg, sender.ChatTag))
                {
                    foreach (var chr in World.GetAllCharacters())
                    {
                        chr.Send(packetOut);
                    }
                }
            }
            else
            {
                var            faction = sender.FactionGroup;
                RealmPacketOut pckt = null, scrambledPckt = null;

                var scrambleDefault               = ScrambleChat && sender.Role.ScrambleChat;
                Func <WorldObject, bool> iterator = obj =>
                {
                    if ((obj is Character))
                    {
                        var chr = (Character)obj;
                        if (!scrambleDefault || chr.FactionGroup == faction || !chr.Role.ScrambleChat)
                        {
                            if (pckt == null)
                            {
                                pckt = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, msg, sender.ChatTag);
                            }
                            chr.Send(pckt);
                        }
                        else
                        {
                            if (scrambledPckt == null)
                            {
                                scrambledPckt = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null,
                                                                      ScrambleMessage(msg), sender.ChatTag);
                            }
                            chr.Send(scrambledPckt);
                        }
                    }
                    return(true);
                };

                if (radius == WorldObject.BroadcastRange)
                {
                    sender.NearbyObjects.Iterate(iterator);
                }
                else
                {
                    sender.IterateEnvironment(radius, iterator);
                }

                if (pckt != null)
                {
                    pckt.Close();
                }
                if (scrambledPckt != null)
                {
                    scrambledPckt.Close();
                }
            }
        }