Ejemplo n.º 1
0
        //public int getSize(bool nameTable)
        //{
        //    // UUID item names.size() unkBool unkIndex (locationData!=null) propertiesOffset unkInt
        //    int size = 16 + Integer.BYTES * 7;

        //    size += ArkArchive.getNameLength(className, nameTable);

        //    if (names != null)
        //    {
        //        size += names.Select(n => ArkArchive.getNameLength(n, nameTable)).Sum();
        //    }

        //    if (locationData != null)
        //    {
        //        size += (int)locationData.Size;
        //    }

        //    return size;
        //}

        //public int getPropertiesSize(bool nameTable)
        //{
        //    int size = ArkArchive.getNameLength(qowyn.ark.properties.Property_Fields.NONE_NAME, nameTable);

        //    size += properties.Select(p => p.calculateSize(nameTable)).Sum();

        //    if (extraData != null)
        //    {
        //        size += extraData.calculateSize(nameTable);
        //    }

        //    return size;
        //}

        public void read(ArkArchive archive)
        {
            var uuidMostSig  = archive.GetLong();
            var uuidLeastSig = archive.GetLong();
            var key          = Tuple.Create(uuidMostSig, uuidLeastSig);

            Guid uuid = Guid.Empty;

            if (!_uuidCache.TryGetValue(key, out uuid))
            {
                var bytes = new byte[16];
                Array.Copy(BitConverter.GetBytes(uuidMostSig), bytes, 8);
                Array.Copy(BitConverter.GetBytes(uuidLeastSig), 0, bytes, 8, 8);
                uuid = new Guid(bytes);
                _uuidCache.Add(key, uuid);
            }
            Uuid = uuid;

            ClassName = archive.GetName();

            IsItem = archive.GetBoolean();

            var countNames = archive.GetInt();

            Names = new List <ArkName>();

            for (int nameIndex = 0; nameIndex < countNames; nameIndex++)
            {
                var instanceName = archive.GetName();


                Names.Add(instanceName);
            }


            UnkBool  = archive.GetBoolean();
            UnkIndex = archive.GetInt();

            var countLocationData = archive.GetInt();

            if (countLocationData > 1)
            {
                _logger.Warn($"countLocationData > 1 at {archive.Position - 4:X}");
            }

            if (countLocationData != 0)
            {
                Location = new LocationData(archive);
            }

            _propertiesOffset = archive.GetInt();

            var shouldBeZero = archive.GetInt();

            if (shouldBeZero != 0)
            {
                _logger.Warn($"Expected int after propertiesOffset to be 0 but found {shouldBeZero} at {archive.Position - 4:X}");
            }
        }