public void Pack(ICustomDataWriter writer)
        {
            CustomDataWriter customWriter = new();

            Serialize(customWriter);

            var size = customWriter.Data.Length;

            uint typeLen = ComputeTypeLen((uint)size);

            writer.WriteShort((short)SubComputeStaticHeader(MessageId, typeLen));
            writer.WriteUInt(GLOBAL_INSTANCE++);

            switch (typeLen)
            {
            case 1:
                writer.WriteByte((byte)size);
                break;

            case 2:
                writer.WriteUShort((ushort)size);
                break;

            case 3:
                writer.WriteByte((byte)(size >> 16 & 255));
                writer.WriteUShort((ushort)(size & 65535));
                break;
            }

            writer.WriteBytes(customWriter.Data);
            customWriter.Dispose();
        }
Example #2
0
        public void Serialize(ICustomDataWriter writer)
        {
            var dataWriter = new CustomDataWriter();

            serializeContent(dataWriter);
            var messageData = dataWriter.GetBytes();

            ushort header = (ushort)(MessageId << 2);

            if (messageData.Length == 0)
            {
                writer.WriteUShort(header);
                return;
            }
            if (messageData.Length <= byte.MaxValue)
            {
                writer.WriteUShort((ushort)(header | 1));
                writer.WriteByte((byte)messageData.Length);
            }
            else if (messageData.Length <= ushort.MaxValue)
            {
                header |= 2;
                writer.WriteUShort(header);
                writer.WriteUShort((ushort)messageData.Length);
            }
            else
            {
                return;
            }

            writer.WriteBytes(messageData);
        }
Example #3
0
        protected override void serializeContent(ICustomDataWriter writer)
        {
            // SelectedServerData (42)
            writer.WriteVarShort(211);    // Server id
            writer.WriteUTF("127.0.0.1"); // Server address
            writer.WriteShort(1);         // Number of ports
            writer.WriteInt(5556);        // Game Server port
            writer.WriteBool(false);      // Can create new character
            var ticket = Guid.NewGuid().ToString().Replace("-", "");

            writer.WriteVarInt(ticket.Length); // Ticket length
            writer.WriteUTFBytes(ticket);      // Ticket

            //SelectedServerDataExtended
            writer.WriteUShort(1); // Number of servers

            // GameServerInformations
            var byteBox = new ByteBox();

            byteBox[0] = false;        // Is Mono account
            byteBox[1] = true;         // Is Selectable
            writer.WriteByte(byteBox.Value);
            writer.WriteVarShort(211); // Server id
            writer.WriteByte(0);       // Type
            writer.WriteByte(3);       // Status
            writer.WriteByte(0);       // Completion
            writer.WriteByte(1);       // Character count
            writer.WriteByte(5);       // Character slots
            writer.WriteDouble(0);     // Date
        }
Example #4
0
        protected override void serializeContent(ICustomDataWriter writer)
        {
            writer.WriteUShort((ushort)Characters.Count); // Number of characters

            foreach (var character in Characters)
            {
                writer.WriteShort((short)character.ProtocolId);
                character.Serialize(writer);
            }

            writer.WriteBool(false); // Has startup actions
        }