//public IDictionary<ArkName, IProperty> Properties //{ // get // { // return properties; // } // set // { // if (value == null) throw new NullReferenceException("Null pointer exception from java"); // properties = value; // } //} //protected internal IDictionary<ArkName, IProperty> properties = new Dictionary<ArkName, IProperty>(); public int getSize(ArkArchive archive) { _isitemOffset = _classNameOffset + archive.GetNameLength(Offset + _classNameOffset); _namesOffset = _isitemOffset + 4; var names = archive.GetInt(Offset + _namesOffset); _unkboolOffset = _namesOffset + 4; for (var i = 0; i < names; i++) { _unkboolOffset += archive.GetNameLength(Offset + _unkboolOffset); } _unkindexOffset = _unkboolOffset + 4; _locationsOffset = _unkindexOffset + 4; var locations = archive.GetInt(Offset + _locationsOffset); if (locations > 1) { _logger.Warn($"countLocationData > 1 at {Offset + _locationsOffset:X}"); } _propertiesoffsetOffset = _locationsOffset + 4 + locations * 6 * 4; _shouldbezeroOffset = _propertiesoffsetOffset + 4; return(_shouldbezeroOffset + 4); //var size = /* uuid */ 16 + archive.GetNameLength(archive.Position + 16) + /* isitem */ 4; //var names = archive.GetInt(archive.Position + size); //size += /* names count */ 4; //for (var i = 0; i < names; i++) size += archive.GetNameLength(archive.Position + size); //size += /* unkbool */ 4 + /* unkindex */ 4; //var locations = archive.GetInt(archive.Position + size); //if (locations > 1) _logger.Warn($"countLocationData > 1 at {archive.Position + size:X}"); //size += /* locations */ 4 + /* location */ locations * 6 * 4 + /* properties offset */ 4 + /* shouldbezero */ 4; //return size; }
public void readBinary(ArkArchive archive) { LocalProfileVersion = archive.GetInt(); if (LocalProfileVersion != 1) { throw new NotSupportedException($@"Unknown Local Profile Version {LocalProfileVersion} in ""{_fileName}""" + (LocalProfileVersion == 0 ? " (possibly corrupt)" : "")); } var unknownDataSize = archive.GetInt(); unknownData = archive.GetBytes(unknownDataSize); var profilesCount = archive.GetInt(); for (int i = 0; i < profilesCount; i++) { Objects.Add(new GameObject(archive, _arkNameCache)); } for (int i = 0; i < profilesCount; i++) { GameObject obj = Objects[i]; if (obj.ClassName.Token.Equals("PrimalLocalProfile")) { _localprofile = obj; } obj.loadProperties(archive, i < profilesCount - 1 ? Objects[i + 1] : null, 0); } }
public void readBinary(ArkArchive archive) { ProfileVersion = archive.GetInt(); if (ProfileVersion != 1) { throw new NotSupportedException($@"Unknown Profile Version {ProfileVersion} in ""{_fileName}""" + (ProfileVersion == 0 ? " (possibly corrupt)" : "")); } var profilesCount = archive.GetInt(); for (var i = 0; i < profilesCount; i++) { Objects.Add(new GameObject(archive, _arkNameCache)); } for (var i = 0; i < profilesCount; i++) { var obj = Objects[i]; if (obj.ClassName.Token.Equals("PrimalPlayerData") || obj.ClassName.Token.Equals("PrimalPlayerDataBP_C")) { _profile = obj; } obj.loadProperties(archive, i < profilesCount - 1 ? Objects[i + 1] : null, 0); } }
public virtual void readBinary(ArkArchive archive) { TribeVersion = archive.GetInt(); if (TribeVersion != 1) { throw new System.NotSupportedException($@"Unknown Tribe Version {TribeVersion} in ""{_fileName}""" + (TribeVersion == 0 ? " (possibly corrupt)" : "")); } var tribesCount = archive.GetInt(); for (int i = 0; i < tribesCount; i++) { Objects.Add(new GameObject(archive, _arkNameCache)); } for (int i = 0; i < tribesCount; i++) { GameObject obj = Objects[i]; if (obj.ClassName.Token.Equals("PrimalTribeData")) { Tribe = obj; } obj.loadProperties(archive, i < tribesCount - 1 ? Objects[i + 1] : null, 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}"); } }
public void readBinary(ArkArchive archive) { var objectCount = archive.GetInt(); for (var i = 0; i < objectCount; i++) { Objects.Add(new GameObject(archive, _arkNameCache)); } for (var i = 0; i < objectCount; i++) { var obj = Objects[i]; obj.loadProperties(archive, i < objectCount - 1 ? Objects[i + 1] : null, 0); if (obj.IsCreature) { Creature = obj; } else if (obj.IsDinoStatusComponent) { Status = obj; } else if (obj.IsTamedCreatureInventory) { Inventory = obj; } } }
public IEnumerable <Tuple <GameObjectReader, GameObjectReader> > GetObjectsEnumerable() { var fi = new FileInfo(_fileName); var size = fi.Length; SaveTime = fi.LastWriteTimeUtc; if (size == 0) { yield break; } //using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(_fileName, FileMode.Open, null, 0L, MemoryMappedFileAccess.Read)) //{ // using (MemoryMappedViewAccessor va = mmf.CreateViewAccessor(0L, 0L, MemoryMappedFileAccess.Read)) // { // ArkArchive archive = new ArkArchive(va, size, _arkNameCache); // if (!_baseRead) readBinaryBase(archive); // else archive.Position = _gameObjectsOffset; // var count = archive.GetInt(); // for (var n = 0; n < count; n++) // { // var gameObject = new GameObjectReader(archive, _arkNameCache) { Index = n }; // archive.Position += gameObject.Size; // yield return gameObject; // } // } //} if (!_baseRead) { readBinaryBase(_archive); } else { _archive.Position = _gameObjectsOffset; } var count = _archive.GetInt(); GameObjectReader prev = null; for (var n = 0; n <= count; n++) { GameObjectReader gameObject = null; if (n < count) { gameObject = new GameObjectReader(_archive, _arkNameCache) { Index = n }; _archive.Position += gameObject.Size; } if (n > 0) { yield return(Tuple.Create(prev, gameObject)); } prev = gameObject; } }
protected void readBinaryHibernation(ArkArchive archive) { archive.Position = hibernationDataOffset; var unk1 = archive.GetInt(); var unk2 = archive.GetInt(); var unk3 = archive.GetInt(); var unk4 = archive.GetInt(); if (archive.Position == nameTableOffset) { return; } var unk5 = archive.GetInt(); var unk6 = archive.GetInt(); var classCount = archive.GetInt(); _hibernationClassNames.Clear(); for (int i = 0; i <= classCount - 1; i++) { _hibernationClassNames.Add(archive.GetString()); } var indicesCount = archive.GetInt(); if (classCount != indicesCount) { throw new NotSupportedException($"Hibernation classCount:{classCount}<>indicesCount:{indicesCount}"); } _hibernationIndices.Clear(); for (int i = 0; i <= indicesCount - 1; i++) { _hibernationIndices.Add(archive.GetInt()); } var entriesCount = archive.GetInt(); _hibernationEntries.Clear(); // needs more refactoring to use parallel execution for (int i = 0; i <= entriesCount - 1; i++) { _hibernationEntries.Add(new HibernationEntry(archive)); } }
public void readBinary(ArkArchive archive) { InventoryVersion = archive.GetInt(); //if (InventoryVersion != 1) // throw new NotSupportedException("Unknown Cloud Inventory Version " + InventoryVersion); var objectCount = archive.GetInt(); for (var i = 0; i < objectCount; i++) { Objects.Add(new GameObject(archive, _arkNameCache)); } for (var i = 0; i < objectCount; i++) { var obj = Objects[i]; if (obj.ClassName.Token.Equals("ArkCloudInventoryData")) { _inventoryData = obj; } obj.loadProperties(archive, i < objectCount - 1 ? Objects[i + 1] : null, 0); } var mydata = InventoryData?.GetPropertyValue <Structs.StructPropertyList>(_myArkData); var dinos = mydata?.GetPropertyValue <Arrays.ArkArrayStruct>(_arkTamedDinosData); if (dinos != null) { InventoryDinoData = dinos.OfType <Structs.StructPropertyList>().Select(x => { var version = x.GetPropertyValue <float?>(_version); if (!version.HasValue) { return(null); } var data = x.GetPropertyValue <Arrays.ArkArrayByte>(_dinoData); return(new ArkCloudInventoryDinoData(version.Value, data, exclusivePropertyNameTree: archive.ExclusivePropertyNameTree)); }).ToArray(); } }
public void readBinary(ArkArchive archive) { var x = archive.GetFloat(); var y = archive.GetFloat(); var z = archive.GetFloat(); var unkByte = archive.GetByte(); var unkFloat = archive.GetFloat(); var nameArchiveSize = archive.GetInt(); var nameArchive = archive.Slice(archive.Position, nameArchiveSize); readBinaryNameTable(nameArchive); archive.Position += nameArchiveSize; var objectArchiveSize = archive.GetInt(); var objectArchive = archive.Slice(archive.Position, objectArchiveSize); readBinaryObjects(objectArchive); archive.Position += objectArchiveSize; var unkInt1 = archive.GetInt(); _classIndex = archive.GetInt(); }
private void readBinaryBase(ArkArchive archive) { readBinaryHeader(archive); if (SaveVersion > 5) { // Name table is located after the objects block, but will be needed to read the objects block readBinaryNameTable(archive); } readBinaryDataFiles(archive); SaveState = new SaveState { GameTime = GameTime, SaveTime = SaveTime, MapName = DataFiles.FirstOrDefault() }; readBinaryEmbeddedData(archive); var unknownValue = archive.GetInt(); if (unknownValue != 0) { //if (unknownValue > 2) //{ // var msg = $"Found unexpected Value {unknownValue} at {archive.Position - 4:X}"; // _logger.Error(msg); // throw new System.NotSupportedException(msg); //} for (int n = 0; n < unknownValue; n++) { archive.GetInt(); //unknownFlags archive.GetInt(); //objectCount archive.GetString(); //name } } _baseRead = true; _gameObjectsOffset = archive.Position; }
private void readBinaryNameTable(ArkArchive archive) { var version = archive.GetInt(); if (version != 3) { throw new NotSupportedException($"hibernation version not supported <>3"); } var nameCount = archive.GetInt(); for (int i = 0; i <= nameCount - 1; i++) { _nameTable.Add(archive.GetString()); } var zoneCount = archive.GetInt(); for (int i = 0; i <= zoneCount - 1; i++) { _zoneVolumes.Add(archive.GetString()); } }
protected void readBinaryObjects(ArkArchive archive, bool gameObjects = true) { if (gameObjects) { var count = archive.GetInt(); Objects.Clear(); for (var n = 0; n < count; n++) { var gameObject = new GameObject(archive, _arkNameCache); gameObject.ObjectId = n; Objects.Add(gameObject); } } }
private void readBinaryObjects(ArkArchive archive) { var objectCount = archive.GetInt(); for (int i = 0; i <= objectCount - 1; i++) { var go = new GameObject(archive); go.ObjectId = i; _objects.Add(go); } archive.SetNameTable(_nameTable, 0, true); for (int n = 0; n <= objectCount - 1; n++) { var go = _objects[n]; _objects[n].loadProperties(archive, (n < _objects.Count - 1) ? _objects[n + 1] : null, 0); } }
protected void readBinaryNameTable(ArkArchive archive) { var position = archive.Position; archive.Position = nameTableOffset; var nameCount = archive.GetInt(); var nameTable = new List <string>(nameCount); for (var n = 0; n < nameCount; n++) { nameTable.Add(archive.GetString()); } archive.NameTable = nameTable; archive.Position = position; }
protected void readBinaryEmbeddedData(ArkArchive archive, bool embeddedData = true) { var count = archive.GetInt(); if (embeddedData) { EmbeddedData.Clear(); for (var n = 0; n < count; n++) { EmbeddedData.Add(new EmbeddedData(archive)); } } else { for (int n = 0; n < count; n++) { Types.EmbeddedData.Skip(archive); } } }
protected void readBinaryDataFiles(ArkArchive archive, bool dataFiles = true) { var count = archive.GetInt(); if (dataFiles) { DataFiles.Clear(); for (var n = 0; n < count; n++) { DataFiles.Add(archive.GetString()); } } else { for (var n = 0; n < count; n++) { archive.SkipString(); } } }
protected void readBinaryHeader(ArkArchive archive) { SaveVersion = archive.GetShort(); if (SaveVersion == 5) { GameTime = archive.GetFloat(); propertiesBlockOffset = 0; } else if (SaveVersion == 6) { nameTableOffset = archive.GetInt(); propertiesBlockOffset = archive.GetInt(); GameTime = archive.GetFloat(); } else if (SaveVersion == 7 || SaveVersion == 8) { binaryDataOffset = archive.GetInt(); var unknownValue = archive.GetInt(); if (unknownValue != 0) { var msg = $"Found unexpected Value {unknownValue} at {archive.Position - 4:X}"; _logger.Error(msg); throw new System.NotSupportedException(msg); } nameTableOffset = archive.GetInt(); propertiesBlockOffset = archive.GetInt(); GameTime = archive.GetFloat(); } else if (SaveVersion == 9) { binaryDataOffset = archive.GetInt(); var unknownValue = archive.GetInt(); if (unknownValue != 0) { var msg = $"Found unexpected Value {unknownValue} at {archive.Position - 4:X}"; _logger.Error(msg); throw new System.NotSupportedException(msg); } nameTableOffset = archive.GetInt(); propertiesBlockOffset = archive.GetInt(); GameTime = archive.GetFloat(); //note: unknown integer value was added in v268.22 with SaveVersion=9 [0x25 (37) on The Island, 0x26 (38) on ragnarok/center/scorched] archive.GetInt(); //unknownValue2 } else { var msg = $"Found unknown Version {SaveVersion}"; _logger.Error(msg); throw new System.NotSupportedException(msg); } }