public void WritePacket(PacketWriter writer)
 {
     writer.WriteInt32((int)FailureReason);
     if (Fingerprint != null)
         writer.WriteString(Fingerprint.ToJson());
     else
         writer.WriteString(null);
     writer.WriteString(HostName);
     writer.WriteString(AssetsRootUrl);
     writer.WriteString(iTunesUrl);
     writer.WriteString(Unknown1);
     writer.WriteInt32(RemainingTime);
     writer.WriteByte(Unknown2);
     writer.WriteByteArray(CompressedFingerprintJson);
     writer.WriteString(Unknown3);
     writer.WriteString(Unknown4);
     File.WriteAllBytes("dump", ((MemoryStream)writer.BaseStream).ToArray());
 }
        public void WritePacket(PacketWriter writer)
        {
            var offset = 0x2A;
            writer.WriteInt32((int)LastVisit.TotalSeconds);
            writer.WriteInt32(Unknown1);
            writer.WriteInt32((int)DateTimeConverter.ToUnixTimestamp(Timestamp));
            writer.WriteInt32(Unknown2);
            writer.WriteInt64(UserID);
            writer.WriteInt32((int)ShieldDuration.TotalSeconds);
            writer.WriteInt32(Unknown3);
            writer.WriteInt32(Unknown4);
            writer.WriteBoolean(Compressed);
            Home.Write(writer);
            writer.WriteInt32(Unknown6);
            writer.WriteInt64(UserID1);
            writer.WriteInt64(UserID2);

            if (Avatar.Clan != null)
            {
                writer.WriteBoolean(true);
                writer.WriteInt64(Avatar.Clan.ID);
                writer.WriteString(Avatar.Clan.Name);
                writer.WriteInt64(Avatar.Clan.Badge);
                writer.WriteInt32(0); // TODO: Make unknown.
                writer.WriteInt64(Avatar.Clan.Level);
                offset += 1;
            }

            writer.WriteBoolean(Unknown7);
            if (Unknown7)
                writer.WriteInt64(Unknown8);
            writer.WriteBoolean(Unknown9);
            if (Unknown9)
                writer.WriteInt64(Unknown10);

            writer.Write(new byte[offset]);
            writer.WriteInt32(Unknown11);
            writer.WriteInt32(AllianceCastleLevel);
            writer.WriteInt32(AllianceCastleUnitCapacity);
            writer.WriteInt32(AllianceCastleUnitCount);
            writer.WriteInt32(Avatar.TownHallLevel);
            writer.WriteString(Avatar.Username);
            writer.WriteString(FacebookID);
            writer.WriteInt32(Unknown14);
            writer.WriteInt32(Unknown15);
            writer.WriteInt32(Avatar.Trophies);
            writer.WriteInt32(Avatar.AttacksWon);
            writer.WriteInt32(Avatar.AttacksLost);
            writer.WriteInt32(Avatar.DefencesWon);
            writer.WriteInt32(Avatar.DefencesLost);
            writer.WriteInt32(Unknown16);
            writer.WriteInt32(Unknown17);
            writer.WriteInt32(Unknown18);
            writer.WriteBoolean(Unknown19);
            if (Unknown19)
                writer.WriteInt64(Unknown20);
            writer.WriteByte(Unknown21);
            writer.WriteInt32(Unknown22);
            writer.WriteInt32(Unknown23);
            writer.WriteInt32(Unknown24);
            writer.WriteInt32(Unknown25);
            for (int i = 0; i < 16; i++)
                writer.WriteInt32(0);
        }