示例#1
0
 public SubPacket(SubPacket original, uint newTargetId)
 {
     header               = new SubPacketHeader();
     gameMessage          = original.gameMessage;
     header.subpacketSize = original.header.subpacketSize;
     header.type          = original.header.type;
     header.sourceId      = original.header.sourceId;
     header.targetId      = newTargetId;
     data = original.data;
 }
示例#2
0
        public unsafe SubPacket(byte[] bytes, ref int offset)
        {
            if (bytes.Length < offset + SUBPACKET_SIZE)
            {
                throw new OverflowException("Packet Error: Subpacket was too small");

                fixed(byte *pdata = &bytes[offset])
                {
                    header = (SubPacketHeader)Marshal.PtrToStructure(new IntPtr(pdata), typeof(SubPacketHeader));
                }

                if (header.type == 0x3)
                {
                    fixed(byte *pdata = &bytes[offset + SUBPACKET_SIZE])
                    {
                        gameMessage =
                            (GameMessageHeader)Marshal.PtrToStructure(new IntPtr(pdata), typeof(GameMessageHeader));
                    }
                }

                if (bytes.Length < offset + header.subpacketSize)
                {
                    throw new OverflowException("Packet Error: Subpacket size didn't equal subpacket data");
                }

                if (header.type == 0x3)
                {
                    data = new byte[header.subpacketSize - SUBPACKET_SIZE - GAMEMESSAGE_SIZE];
                    Array.Copy(bytes, offset + SUBPACKET_SIZE + GAMEMESSAGE_SIZE, data, 0, data.Length);
                }
                else
                {
                    data = new byte[header.subpacketSize - SUBPACKET_SIZE];
                    Array.Copy(bytes, offset + SUBPACKET_SIZE, data, 0, data.Length);
                }

                offset += header.subpacketSize;
        }
示例#3
0
        public SubPacket(bool isGameMessage, ushort opcode, uint sourceId, byte[] data)
        {
            header = new SubPacketHeader();

            if (isGameMessage)
            {
                gameMessage           = new GameMessageHeader();
                gameMessage.opcode    = opcode;
                gameMessage.timestamp = Utils.UnixTimeStampUTC();
                gameMessage.unknown4  = 0x14;
                gameMessage.unknown5  = 0x00;
                gameMessage.unknown6  = 0x00;
            }

            header.sourceId = sourceId;
            header.targetId = 0;

            if (isGameMessage)
            {
                header.type = 0x03;
            }
            else
            {
                header.type = opcode;
            }

            header.unknown1 = 0x00;

            this.data = data;

            header.subpacketSize = (ushort)(SUBPACKET_SIZE + data.Length);

            if (isGameMessage)
            {
                header.subpacketSize += GAMEMESSAGE_SIZE;
            }
        }