Beispiel #1
0
        public int Unknown4; // 0

        /// <summary>
        /// Reads the <see cref="VillageData"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="VillageData"/>.
        /// </param>
        /// <exception cref="NotImplementedException">Compressed set to false.</exception>
        /// <exception cref="InvalidMessageException">Home data array is null.</exception>
        public void Read(MessageReader reader)
        {
            if (!Compressed)
                throw new NotImplementedException("Uncompressed Village definition is not implemented.");

            Unknown1 = reader.ReadInt32(); // 0
            UserID = reader.ReadInt64();
            ShieldDuration = TimeSpan.FromSeconds(reader.ReadInt32());
            Unknown2 = reader.ReadInt32(); // 1200
            Unknown3 = reader.ReadInt32(); // 60
            Compressed = reader.ReadBoolean();

            var homeData = reader.ReadBytes();
            if (homeData == null)
                throw new InvalidMessageException("No data was provided about Village.");

            using (var br = new BinaryReader(new MemoryStream(homeData))) // little endian
            {
                var decompressedLength = br.ReadInt32();
                var compressedHome = br.ReadBytes(homeData.Length - 4); // -4 to remove the decompressedLength bytes read
                var homeJson = ZlibStream.UncompressString(compressedHome);
                Home = Village.FromJson(homeJson);
            }

            Unknown4 = reader.ReadInt32();
        }
Beispiel #2
0
        /// <summary>
        /// Reads the <see cref="AvatarData"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="AvatarData"/>.
        /// </param>
        public void Read(MessageReader reader)
        {
            OwnVillageData = new VillageData();
            OwnVillageData.Read(reader);

            UserID = reader.ReadInt64();
            UserID2 = reader.ReadInt64();
            OwnClanData = new ClanData();
            if (reader.ReadBoolean())
            {
                OwnClanData.ID = reader.ReadInt64();
                OwnClanData.Name = reader.ReadString();
                OwnClanData.Badge = reader.ReadInt32();
                OwnClanData.Role = reader.ReadInt32();
                OwnClanData.Level = reader.ReadInt32();
                OwnClanData.Unknown1 = reader.ReadByte();
            }
            Unknown1 = reader.ReadInt32();

            Unknown2 = reader.ReadInt32();
            Unknown3 = reader.ReadInt32();
            Unknown4 = reader.ReadInt32();
            Unknown5 = reader.ReadInt32();
            Unknown6 = reader.ReadInt32();
            Unknown7 = reader.ReadInt32();
            Unknown8 = reader.ReadInt32();
            Unknown9 = reader.ReadInt32();
            Unknown10 = reader.ReadInt32();
            Unknown11 = reader.ReadInt32();

            League = reader.ReadInt32();
            AllianceCastleLevel = reader.ReadInt32();
            AllianceCastleTotalCapacity = reader.ReadInt32();
            AllianceCastleUsedCapacity = reader.ReadInt32();
            TownHallLevel = reader.ReadInt32();
            Name = reader.ReadString();

            Unknown12 = reader.ReadInt32();

            Level = reader.ReadInt32();
            Experience = reader.ReadInt32();
            Gems = reader.ReadInt32();
            FreeGems = reader.ReadInt32();

            Unknown13 = reader.ReadInt32();
            Unknown14 = reader.ReadInt32();

            Trophies = reader.ReadInt32();

            AttacksWon = reader.ReadInt32();
            AttacksLost = reader.ReadInt32();
            DefensesWon = reader.ReadInt32();
            DefensesLost = reader.ReadInt32();
            Unknown19 = reader.ReadInt32();
            Unknown20 = reader.ReadInt32();
            Unknown21 = reader.ReadInt32();
            Unknown22 = reader.ReadByte();
            Unknown23 = reader.ReadInt64();

            IsNamed = reader.ReadBoolean();

            Unknown24 = reader.ReadInt32();
            Unknown25 = reader.ReadInt32();
            Unknown26 = reader.ReadInt32();
            Unknown27 = reader.ReadInt32();

            ResourcesCapacity = Slot.ReadSlotArray<ResourceCapacitySlot>(reader);
            ResourcesAmount = Slot.ReadSlotArray<ResourceAmountSlot>(reader);
            Units = Slot.ReadSlotArray<UnitSlot>(reader);
            Spells = Slot.ReadSlotArray<SpellSlot>(reader);
            UnitUpgrades = Slot.ReadSlotArray<UnitUpgradeSlot>(reader);
            SpellUpgrades = Slot.ReadSlotArray<SpellUpgradeSlot>(reader);
            HeroUpgrades = Slot.ReadSlotArray<HeroUpgradeSlot>(reader);
            HeroHealths = Slot.ReadSlotArray<HeroHealthSlot>(reader);
            HeroStates = Slot.ReadSlotArray<HeroStateSlot>(reader);
            TutorialProgess = Slot.ReadSlotArray<TutorialProgressSlot>(reader);
            Acheivements = Slot.ReadSlotArray<AchievementSlot>(reader);
            AcheivementProgress = Slot.ReadSlotArray<AchievementProgessSlot>(reader);
            NpcStars = Slot.ReadSlotArray<NpcStarSlot>(reader);
            NpcGold = Slot.ReadSlotArray<NpcGoldSlot>(reader);
            NpcElixir = Slot.ReadSlotArray<NpcElixirSlot>(reader);

            Unknown28 = reader.ReadInt32();
        }