示例#1
0
        public void SendUserDialog(string first, string last, string objectName, string message, string[] buttons)
        {
            Random             rand   = new Random();
            ScriptDialogPacket packet = new ScriptDialogPacket();

            packet.Data.ObjectID   = UUID.Random();
            packet.Data.FirstName  = Utils.StringToBytes(first);
            packet.Data.LastName   = Utils.StringToBytes(last);
            packet.Data.ObjectName = Utils.StringToBytes(objectName);
            packet.Data.Message    = Utils.StringToBytes(message);
            packet.Header.Reliable = true;
            packet.Type            = PacketType.ScriptDialog;

            packet.Data.ChatChannel = (byte)rand.Next(1000, 10000);
            packet.Data.ImageID     = UUID.Zero;

            ScriptDialogPacket.ButtonsBlock[] temp = new ScriptDialogPacket.ButtonsBlock[buttons.Length];
            for (int i = 0; i < buttons.Length; i++)
            {
                temp[i]             = new ScriptDialogPacket.ButtonsBlock();
                temp[i].ButtonLabel = Utils.StringToBytes(buttons[i]);
            }
            packet.Buttons = temp;
            proxy.InjectPacket(packet, Direction.Incoming);
        }
示例#2
0
        public void ToBytesMultiple()
        {
            UUID testID = UUID.Random();

            DirPlacesReplyPacket bigPacket = new DirPlacesReplyPacket();

            bigPacket.Header.Zerocoded    = false;
            bigPacket.Header.Sequence     = 42;
            bigPacket.Header.AppendedAcks = true;
            bigPacket.Header.AckList      = new uint[50];
            for (int i = 0; i < bigPacket.Header.AckList.Length; i++)
            {
                bigPacket.Header.AckList[i] = (uint)i;
            }
            bigPacket.AgentData.AgentID = testID;
            bigPacket.QueryData         = new DirPlacesReplyPacket.QueryDataBlock[100];
            for (int i = 0; i < bigPacket.QueryData.Length; i++)
            {
                bigPacket.QueryData[i]         = new DirPlacesReplyPacket.QueryDataBlock();
                bigPacket.QueryData[i].QueryID = testID;
            }
            bigPacket.QueryReplies = new DirPlacesReplyPacket.QueryRepliesBlock[100];
            for (int i = 0; i < bigPacket.QueryReplies.Length; i++)
            {
                bigPacket.QueryReplies[i]          = new DirPlacesReplyPacket.QueryRepliesBlock();
                bigPacket.QueryReplies[i].Auction  = (i & 1) == 0;
                bigPacket.QueryReplies[i].Dwell    = (float)i;
                bigPacket.QueryReplies[i].ForSale  = (i & 1) == 0;
                bigPacket.QueryReplies[i].Name     = Utils.StringToBytes("DirPlacesReply Test String");
                bigPacket.QueryReplies[i].ParcelID = testID;
            }
            bigPacket.StatusData = new DirPlacesReplyPacket.StatusDataBlock[100];
            for (int i = 0; i < bigPacket.StatusData.Length; i++)
            {
                bigPacket.StatusData[i]        = new DirPlacesReplyPacket.StatusDataBlock();
                bigPacket.StatusData[i].Status = (uint)i;
            }

            byte[][] splitPackets = bigPacket.ToBytesMultiple();

            int queryDataCount    = 0;
            int queryRepliesCount = 0;
            int statusDataCount   = 0;

            for (int i = 0; i < splitPackets.Length; i++)
            {
                byte[] packetData           = splitPackets[i];
                int    len                  = packetData.Length - 1;
                DirPlacesReplyPacket packet = (DirPlacesReplyPacket)Packet.BuildPacket(packetData, ref len, packetData);

                Assert.IsTrue(packet.AgentData.AgentID == bigPacket.AgentData.AgentID);

                for (int j = 0; j < packet.QueryReplies.Length; j++)
                {
                    Assert.IsTrue(packet.QueryReplies[j].Dwell == (float)(queryRepliesCount + j),
                                  "Expected Dwell of " + (float)(queryRepliesCount + j) + " but got " + packet.QueryReplies[j].Dwell);
                    Assert.IsTrue(packet.QueryReplies[j].ParcelID == testID);
                }

                queryDataCount    += packet.QueryData.Length;
                queryRepliesCount += packet.QueryReplies.Length;
                statusDataCount   += packet.StatusData.Length;
            }

            Assert.IsTrue(queryDataCount == bigPacket.QueryData.Length);
            Assert.IsTrue(queryRepliesCount == bigPacket.QueryData.Length);
            Assert.IsTrue(statusDataCount == bigPacket.StatusData.Length);

            ScriptDialogPacket scriptDialogPacket = new ScriptDialogPacket();

            scriptDialogPacket.Data.ChatChannel = 0;
            scriptDialogPacket.Data.FirstName   = Utils.EmptyBytes;
            scriptDialogPacket.Data.ImageID     = UUID.Zero;
            scriptDialogPacket.Data.LastName    = Utils.EmptyBytes;
            scriptDialogPacket.Data.Message     = Utils.EmptyBytes;
            scriptDialogPacket.Data.ObjectID    = UUID.Zero;
            scriptDialogPacket.Data.ObjectName  = Utils.EmptyBytes;
            scriptDialogPacket.Buttons          = new ScriptDialogPacket.ButtonsBlock[0];

            byte[][] splitPacket = scriptDialogPacket.ToBytesMultiple();

            Assert.IsNotNull(splitPacket);
            Assert.IsTrue(splitPacket.Length == 1, "Expected ScriptDialog packet to split into 1 packet but got " + splitPacket.Length);

            ParcelReturnObjectsPacket proPacket = new ParcelReturnObjectsPacket();

            proPacket.AgentData.AgentID     = UUID.Zero;
            proPacket.AgentData.SessionID   = UUID.Zero;
            proPacket.ParcelData.LocalID    = 0;
            proPacket.ParcelData.ReturnType = 0;
            proPacket.TaskIDs             = new ParcelReturnObjectsPacket.TaskIDsBlock[0];
            proPacket.OwnerIDs            = new ParcelReturnObjectsPacket.OwnerIDsBlock[1];
            proPacket.OwnerIDs[0]         = new ParcelReturnObjectsPacket.OwnerIDsBlock();
            proPacket.OwnerIDs[0].OwnerID = UUID.Zero;

            splitPacket = proPacket.ToBytesMultiple();

            Assert.IsNotNull(splitPacket);
            Assert.IsTrue(splitPacket.Length == 1, "Expected ParcelReturnObjectsPacket packet to split into 1 packet but got " + splitPacket.Length);

            InventoryDescendentsPacket invPacket = new InventoryDescendentsPacket();

            invPacket.FolderData         = new InventoryDescendentsPacket.FolderDataBlock[1];
            invPacket.FolderData[0]      = new InventoryDescendentsPacket.FolderDataBlock();
            invPacket.FolderData[0].Name = Utils.EmptyBytes;
            invPacket.ItemData           = new InventoryDescendentsPacket.ItemDataBlock[5];
            for (int i = 0; i < 5; i++)
            {
                invPacket.ItemData[i]             = new InventoryDescendentsPacket.ItemDataBlock();
                invPacket.ItemData[i].Description = Utils.StringToBytes("Unit Test Item Description");
                invPacket.ItemData[i].Name        = Utils.StringToBytes("Unit Test Item Name");
            }

            splitPacket = invPacket.ToBytesMultiple();

            Assert.IsNotNull(splitPacket);
            Assert.IsTrue(splitPacket.Length == 1, "Split InventoryDescendents packet into " + splitPacket.Length + " instead of 1 packet");

            int x = 0;
            int y = splitPacket[0].Length - 1;

            invPacket.FromBytes(splitPacket[0], ref x, ref y, null);

            Assert.IsTrue(invPacket.FolderData.Length == 1, "InventoryDescendents packet came back with " + invPacket.FolderData.Length + " FolderData blocks");
            Assert.IsTrue(invPacket.ItemData.Length == 5, "InventoryDescendents packet came back with " + invPacket.ItemData.Length + " ItemData blocks");
        }
        public void ToBytesMultiple()
        {
            UUID testID = UUID.Random();

            DirPlacesReplyPacket bigPacket = new DirPlacesReplyPacket();
            bigPacket.Header.Zerocoded = false;
            bigPacket.Header.Sequence = 42;
            bigPacket.Header.AppendedAcks = true;
            bigPacket.Header.AckList = new uint[50];
            for (int i = 0; i < bigPacket.Header.AckList.Length; i++) { bigPacket.Header.AckList[i] = (uint)i; }
            bigPacket.AgentData.AgentID = testID;
            bigPacket.QueryData = new DirPlacesReplyPacket.QueryDataBlock[100];
            for (int i = 0; i < bigPacket.QueryData.Length; i++)
            {
                bigPacket.QueryData[i] = new DirPlacesReplyPacket.QueryDataBlock();
                bigPacket.QueryData[i].QueryID = testID;
            }

            bigPacket.QueryReplies = new DirPlacesReplyPacket.QueryRepliesBlock[100];
            for (int i = 0; i < bigPacket.QueryReplies.Length; i++)
            {
                bigPacket.QueryReplies[i] = new DirPlacesReplyPacket.QueryRepliesBlock();
                bigPacket.QueryReplies[i].Auction = (i & 1) == 0;
                bigPacket.QueryReplies[i].Dwell = (float)i;
                bigPacket.QueryReplies[i].ForSale = (i & 1) == 0;
                bigPacket.QueryReplies[i].Name = Utils.StringToBytes("DirPlacesReply Test String");
                bigPacket.QueryReplies[i].ParcelID = testID;
            }

            bigPacket.StatusData = new DirPlacesReplyPacket.StatusDataBlock[100];
            for (int i = 0; i < bigPacket.StatusData.Length; i++)
            {
                bigPacket.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock();
                bigPacket.StatusData[i].Status = (uint)i;
            }

            byte[][] splitPackets = bigPacket.ToBytesMultiple();

            int queryDataCount = 0;
            int queryRepliesCount = 0;
            int statusDataCount = 0;
            for (int i = 0; i < splitPackets.Length; i++)
            {
                byte[] packetData = splitPackets[i];
                int len = packetData.Length - 1;
                DirPlacesReplyPacket packet = (DirPlacesReplyPacket)Packet.BuildPacket(packetData, ref len, packetData);

                Assert.IsTrue(packet.AgentData.AgentID == bigPacket.AgentData.AgentID);

                for (int j = 0; j < packet.QueryReplies.Length; j++)
                {
                    Assert.IsTrue(packet.QueryReplies[j].Dwell == (float)(queryRepliesCount + j),
                        "Expected Dwell of " + (float)(queryRepliesCount + j) + " but got " + packet.QueryReplies[j].Dwell);
                    Assert.IsTrue(packet.QueryReplies[j].ParcelID == testID);
                }

                queryDataCount += packet.QueryData.Length;
                queryRepliesCount += packet.QueryReplies.Length;
                statusDataCount += packet.StatusData.Length;
            }

            Assert.IsTrue(queryDataCount == bigPacket.QueryData.Length);
            Assert.IsTrue(queryRepliesCount == bigPacket.QueryData.Length);
            Assert.IsTrue(statusDataCount == bigPacket.StatusData.Length);

            ScriptDialogPacket scriptDialogPacket = new ScriptDialogPacket();
            scriptDialogPacket.Data.ChatChannel = 0;
            scriptDialogPacket.Data.FirstName = Utils.EmptyBytes;
            scriptDialogPacket.Data.ImageID = UUID.Zero;
            scriptDialogPacket.Data.LastName = Utils.EmptyBytes;
            scriptDialogPacket.Data.Message = Utils.EmptyBytes;
            scriptDialogPacket.Data.ObjectID = UUID.Zero;
            scriptDialogPacket.Data.ObjectName = Utils.EmptyBytes;
            scriptDialogPacket.Buttons = new ScriptDialogPacket.ButtonsBlock[0];
            scriptDialogPacket.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
            scriptDialogPacket.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
            scriptDialogPacket.OwnerData[0].OwnerID = UUID.Zero;

            byte[][] splitPacket = scriptDialogPacket.ToBytesMultiple();

            Assert.IsNotNull(splitPacket);
            Assert.IsTrue(splitPacket.Length == 1, "Expected ScriptDialog packet to split into 1 packet but got " + splitPacket.Length);

            ParcelReturnObjectsPacket proPacket = new ParcelReturnObjectsPacket();
            proPacket.AgentData.AgentID = UUID.Zero;
            proPacket.AgentData.SessionID = UUID.Zero;
            proPacket.ParcelData.LocalID = 0;
            proPacket.ParcelData.ReturnType = 0;
            proPacket.TaskIDs = new ParcelReturnObjectsPacket.TaskIDsBlock[0];
            proPacket.OwnerIDs = new ParcelReturnObjectsPacket.OwnerIDsBlock[1];
            proPacket.OwnerIDs[0] = new ParcelReturnObjectsPacket.OwnerIDsBlock();
            proPacket.OwnerIDs[0].OwnerID = UUID.Zero;

            splitPacket = proPacket.ToBytesMultiple();

            Assert.IsNotNull(splitPacket);
            Assert.IsTrue(splitPacket.Length == 1, "Expected ParcelReturnObjectsPacket packet to split into 1 packet but got " + splitPacket.Length);

            InventoryDescendentsPacket invPacket = new InventoryDescendentsPacket();
            invPacket.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
            invPacket.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
            invPacket.FolderData[0].Name = Utils.EmptyBytes;
            invPacket.ItemData = new InventoryDescendentsPacket.ItemDataBlock[5];
            for (int i = 0; i < 5; i++)
            {
                invPacket.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
                invPacket.ItemData[i].Description = Utils.StringToBytes("Unit Test Item Description");
                invPacket.ItemData[i].Name = Utils.StringToBytes("Unit Test Item Name");
            }

            splitPacket = invPacket.ToBytesMultiple();

            Assert.IsNotNull(splitPacket);
            Assert.IsTrue(splitPacket.Length == 1, "Split InventoryDescendents packet into " + splitPacket.Length + " instead of 1 packet");

            int x = 0;
            int y = splitPacket[0].Length - 1;
            invPacket.FromBytes(splitPacket[0], ref x, ref y, null);

            Assert.IsTrue(invPacket.FolderData.Length == 1, "InventoryDescendents packet came back with " + invPacket.FolderData.Length + " FolderData blocks");
            Assert.IsTrue(invPacket.ItemData.Length == 5, "InventoryDescendents packet came back with " + invPacket.ItemData.Length + " ItemData blocks");
        }
示例#4
0
        private void SendUserDialog(string first, string last, string objectName, string message, string[] buttons)
        {
            Random rand = new Random();
            ScriptDialogPacket packet = new ScriptDialogPacket();
            packet.Data.ObjectID = UUID.Random();
            packet.Data.FirstName = Utils.StringToBytes(first);
            packet.Data.LastName = Utils.StringToBytes(last);
            packet.Data.ObjectName = Utils.StringToBytes(objectName);
            packet.Data.Message = Utils.StringToBytes(message);
            packet.Data.ChatChannel = (byte)rand.Next(1000, 10000);
            packet.Data.ImageID = UUID.Zero;

            ScriptDialogPacket.ButtonsBlock[] temp = new ScriptDialogPacket.ButtonsBlock[buttons.Length];
            for (int i = 0; i < buttons.Length; i++)
            {
                temp[i] = new ScriptDialogPacket.ButtonsBlock();
                temp[i].ButtonLabel = Utils.StringToBytes(buttons[i]);
            }
            packet.Buttons = temp;
            proxy.InjectPacket(packet, Direction.Incoming);
        }
示例#5
0
文件: SpamBlock.cs 项目: zadark/par
 public diags(ScriptDialogPacket ss)
 {
     s = ss; time = System.DateTime.Now;
 }
示例#6
0
文件: SpamBlock.cs 项目: zadark/par
        private Packet Dialogs(Packet packet, IPEndPoint sim)
        {
            lock (recSeq)
            {
                if (!recSeq.Contains(packet.Header.Sequence))
                {
                    recSeq.Add(packet.Header.Sequence);
                    if (recSeq.Count > 200)
                    {
                        recSeq.Clear();
                    }
                    if (form.getCheckDiag())
                    {
                        ScriptDialogPacket s = (ScriptDialogPacket)packet;

                        lock (lastDialogs)
                        {
                            lastDialogs.Add(new diags((ScriptDialogPacket)packet));
                            if (lastDialogs.Count > 4)
                            {
                                lastDialogs.RemoveAt(0);
                            }
                        }

                        List <UUID> whos = new List <UUID>();
                        lock (lastDialogs)
                        {
                            //proxy.writethis("new", ConsoleColor.Black, ConsoleColor.Blue);
                            foreach (diags d in lastDialogs)
                            {
                                ScriptDialogPacket p = d.s;
                                UUID who             = p.Data.ObjectID;
                                if (!whos.Contains(who))
                                {
                                    whos.Add(who);
                                }

                                //proxy.writethis(d.ToString(), ConsoleColor.Black, ConsoleColor.Cyan);
                            }
                        }

                        if (lastDialogs.Count == 4)
                        {
                            TimeSpan duration = lastDialogs[3].time - lastDialogs[0].time;
                            //proxy.writethis(durationToString(), ConsoleColor.Black, ConsoleColor.DarkCyan);
                            if (duration.TotalMilliseconds < 400)
                            {
                                form.textBox1.Text += "DD";
                                //proxy.writeinthis("DD", ConsoleColor.Black, ConsoleColor.Red);
                                return(null);
                            }
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            return(packet);
        }
示例#7
0
文件: SpamBlock.cs 项目: zadark/par
 public diags(ScriptDialogPacket ss)
 {
     s = ss; time = System.DateTime.Now;
 }