/// <summary>
        /// Writes the <see cref="OwnHomeDataMessage"/> to the specified <see cref="MessageWriter"/>.
        /// </summary>
        /// <param name="writer">
        /// <see cref="MessageWriter"/> that will be used to write the <see cref="OwnHomeDataMessage"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="writer"/> is null.</exception>
        /// <exception cref="InvalidOperationException"><see cref="OwnVillageData"/> is null.</exception>
        /// <exception cref="InvalidOperationException"><see cref="OwnAvatarData"/> is null.</exception>
        public override void WriteMessage(MessageWriter writer)
        {
            ThrowIfWriterNull(writer);

            if (OwnVillageData == null)
            {
                throw new InvalidOperationException("OwnVillageData cannot be null.");
            }
            if (OwnAvatarData == null)
            {
                throw new InvalidOperationException("OwnAvatarData cannot be null.");
            }

            writer.Write((int)LastVisit.TotalSeconds);

            writer.Write(Unknown1); // -1

            writer.Write((int)TimeUtils.ToUnixTimestamp(Timestamp));
            OwnVillageData.WriteMessageComponent(writer);

            OwnAvatarData.WriteMessageComponent(writer);

            writer.Write(Unknown2);
            writer.Write(Unknown3);

            writer.Write(Unkonwn4); // 1462629754000
            writer.Write(Unknown5); // 1462629754000
            writer.Write(Unknown6); // 1462631554000
        }
示例#2
0
        /// <summary>
        /// Writes the <see cref="VisitHomeDataMessage"/> to the specified <see cref="MessageWriter"/>.
        /// </summary>
        /// <param name="writer">
        /// <see cref="MessageWriter"/> that will be used to write the <see cref="VisitHomeDataMessage"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="writer"/> is null.</exception>
        /// <exception cref="InvalidOperationException"><see cref="VisitVillageData"/> is null.</exception>
        /// <exception cref="InvalidOperationException"><see cref="VisitAvatarData"/> is null.</exception>
        /// <exception cref="InvalidOperationException"><see cref="OwnAvatarData"/> is null.</exception>
        public override void WriteMessage(MessageWriter writer)
        {
            ThrowIfWriterNull(writer);

            if (VisitVillageData == null)
            {
                throw new InvalidOperationException("EnemyVillageData cannot be null.");
            }
            if (VisitAvatarData == null)
            {
                throw new InvalidOperationException("EnemyHomeAvatarData cannot be null.");
            }
            if (OwnAvatarData == null)
            {
                throw new InvalidOperationException("OwnAvatarData cannot be null.");
            }

            writer.Write((int)LastVisit.TotalSeconds);
            writer.Write((int)TimeUtils.ToUnixTimestamp(Timestamp));
            VisitVillageData.WriteMessageComponent(writer);
            VisitAvatarData.WriteMessageComponent(writer);

            writer.Write(Unknown1);
            writer.Write(Unknown2);

            OwnAvatarData.WriteMessageComponent(writer);
        }
        /// <summary>
        /// Writes the <see cref="AvatarProfileResponseMessage"/> to the specified <see cref="MessageWriter"/>.
        /// </summary>
        /// <param name="writer">
        /// <see cref="MessageWriter"/> that will be used to write the <see cref="AvatarProfileResponseMessage"/>.
        /// </param>
        public override void WriteMessage(MessageWriter writer)
        {
            if (AvatarData == null)
            {
                throw new InvalidOperationException("AvatarData cannot be null.");
            }

            AvatarData.WriteMessageComponent(writer);

            var mem = new MemoryStream();

            using (var bw = new BinaryWriter(mem))
            {
                var villageJson       = VillageJson;
                var compressedVillage = ZlibStream.CompressString(villageJson);

                bw.Write(villageJson.Length);
                bw.Write(compressedVillage);
                writer.Write(mem.ToArray(), true);
            }

            writer.Write(TroopsDonated);
            writer.Write(TroopsReceived);
            writer.Write((int)WarCoolDown.TotalSeconds);

            writer.Write(Unknown2);
            writer.Write(Unknown3);
        }
示例#4
0
        /// <summary>
        /// Writes the <see cref="NpcDataMessage"/> to the specified <see cref="MessageWriter"/>.
        /// </summary>
        /// <param name="writer">
        /// <see cref="MessageWriter"/> that will be used to write the <see cref="NpcDataMessage"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="writer"/> is null.</exception>
        /// <exception cref="InvalidOperationException"><see cref="AvatarData"/> is null.</exception>
        public override void WriteMessage(MessageWriter writer)
        {
            ThrowIfWriterNull(writer);

            if (AvatarData == null)
            {
                throw new InvalidOperationException("NpcAvatarData cannot be null.");
            }

            writer.Write(Unknown1);

            writer.Write(NpcVillageJson);
            AvatarData.WriteMessageComponent(writer);

            writer.Write(Unknown2);

            writer.Write(NpcId);
        }