public static ItemData ReadItemData(IBitReader reader, ushort version) { if (version < 6) { throw new NotSupportedException(); } var unknown1 = reader.ReadUInt32(); var partitionName = reader.ReadString(); ItemDefinition itemDefinition; partitionName = partitionName.ToLowerInvariant(); if (InfoManager.Items.TryGetValue(partitionName, out itemDefinition) == false) { throw new NotSupportedException(); } var itemData = ItemDataFactory.Create(itemDefinition.Type); itemData.Unknown1 = unknown1; itemData.PartitionName = partitionName; itemData.Definition = itemDefinition; itemData.Read(reader, version); return(itemData); }
internal override void Read1(IBitReader reader, ushort arg1) { base.Read1(reader, arg1); reader.PushFrameLength(24); this._Unknown.Clear(); var unknown1Count = reader.ReadUInt16(); for (int i = 0; i < unknown1Count; i++) { reader.PushFrameLength(24); var unknown1Key = reader.ReadString(); var unknown1Value = reader.ReadString(); reader.PopFrameLength(); this._Unknown.Add(new KeyValuePair <string, string>(unknown1Key, unknown1Value)); } reader.PopFrameLength(); }
public static void ReadStringDictionary(this IBitReader reader, Dictionary <string, string> dictionary) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } dictionary.Clear(); var count = reader.ReadUInt16(); for (var i = 0; i < count; i++) { reader.PushFrameLength(24); var key = reader.ReadString(); var value = reader.ReadString(); reader.PopFrameLength(); dictionary.Add(key, value); } }
internal void Read(IBitReader reader, ushort version) { reader.PushFrameLength(24); this._Unknown1 = reader.ReadUInt32(); this._Unknown2.Read(reader, version); if (version >= 4) { this._Unknown3 = reader.ReadString(); } this._Unknown4 = reader.ReadUInt32(); reader.PopFrameLength(); }
public static void ReadStringList(this IBitReader reader, List <string> list) { if (list == null) { throw new ArgumentNullException("list"); } list.Clear(); var count = reader.ReadUInt16(); for (int i = 0; i < count; i++) { list.Add(reader.ReadString()); } }
public override void Read(IBitReader reader, ushort version) { this._Unknown4 = reader.ReadBoolean(); var modCount = Math.Min(5, (int)reader.ReadUInt16()); for (int i = 0; i < modCount; i++) { reader.PushFrameLength(24); if (version >= 9) { var modId = reader.ReadUInt32(); if (modId != 0) { reader.PushFrameLength(24); var modItem = Components.InventoryComponent.ReadItemData(reader, version); reader.PopFrameLength(); this._Mods.Add(new KeyValuePair <uint, ItemData>(modId, modItem)); } } else { throw new NotSupportedException(); } reader.PopFrameLength(); } var augmentationCount = reader.ReadUInt16(); for (int i = 0; i < augmentationCount; i++) { reader.PushFrameLength(24); var augmentationItemHash = reader.ReadUInt32(); this._AugmentationItemHashes.Add(augmentationItemHash); reader.PopFrameLength(); } this._CustomName = reader.ReadString(); base.Read(reader, version); }
private D2S(IBitReader reader) { Header = Header.Read(reader); ActiveWeapon = reader.ReadUInt32(); Name = reader.ReadString(16); Status = Status.Read(reader.ReadByte()); Progression = reader.ReadByte(); Unk0x0026 = reader.ReadBytes(2); ClassId = reader.ReadByte(); Unk0x0029 = reader.ReadBytes(2); Level = reader.ReadByte(); Created = reader.ReadUInt32(); LastPlayed = reader.ReadUInt32(); Unk0x0034 = reader.ReadBytes(4); AssignedSkills = Enumerable.Range(0, 16).Select(_ => Skill.Read(reader)).ToArray(); LeftSkill = Skill.Read(reader); RightSkill = Skill.Read(reader); LeftSwapSkill = Skill.Read(reader); RightSwapSkill = Skill.Read(reader); Appearances = Appearances.Read(reader); Location = Locations.Read(reader); MapId = reader.ReadUInt32(); Unk0x00af = reader.ReadBytes(2); Mercenary = Mercenary.Read(reader); RealmData = reader.ReadBytes(140); Quests = QuestsSection.Read(reader); Waypoints = WaypointsSection.Read(reader); NPCDialog = NPCDialogSection.Read(reader); Attributes = Attributes.Read(reader); ClassSkills = ClassSkills.Read(reader, ClassId); PlayerItemList = ItemList.Read(reader, Header.Version); PlayerCorpses = CorpseList.Read(reader, Header.Version); if (Status.IsExpansion) { MercenaryItemList = MercenaryItemList.Read(reader, Mercenary, Header.Version); Golem = Golem.Read(reader, Header.Version); } }
internal void Read(IBitReader reader) { reader.PushFrameLength(24); this._Unknown1 = reader.ReadUInt8(); this._Unknown2.Clear(); var unknown2Count = reader.ReadUInt16(); for (int i = 0; i < unknown2Count; i++) { this._Unknown2.Add(reader.ReadUInt8()); } this._Unknown3 = reader.ReadString(); this._Unknown4.Clear(); var unknown4Count = reader.ReadUInt32(); for (uint i = 0; i < unknown4Count; i++) { var unknown4 = new DestructionUnknown1(); unknown4.Read(reader); this._Unknown4.Add(unknown4); } this._Unknown5 = reader.ReadUInt32(); reader.PopFrameLength(); }
public override void Read(IBitReader reader) { base.Read(reader); this._Timestamp = ImportTimestamp(reader.ReadUInt64()); this._SaveFileName = reader.ReadString(); var gameVersion = reader.ReadUInt16(); var saveVersion = reader.ReadUInt16(); var unknown1 = reader.ReadUInt16(); // 10 var unknown2 = reader.ReadUInt16(); // 0 this._UserBuildInfo = reader.ReadUInt32(); if (gameVersion != 3) { throw new SaveFormatException("unsupported save data game version"); } if (saveVersion < 20 || saveVersion > 22) { throw new SaveFormatException("unsupported save data save version"); } if (unknown1 != 10 || unknown2 != 0) { throw new SaveFormatException("unsupported save data header data"); } this._LevelName = reader.ReadString(); this._Unknown1 = reader.ReadUInt32(); reader.ReadStringList(this._PreloadedBundleNames); reader.ReadStringDictionary(this._LayerInclusion); var bundleHeapCount = reader.ReadUInt16(12); this._BundleHeaps.Clear(); for (int i = 0; i < bundleHeapCount; i++) { reader.PushFrameLength(24); var bundleHeap = new Data.BundleHeapInfo(); bundleHeap.Unknown1 = reader.ReadString(); bundleHeap.Unknown2 = reader.ReadUInt32(); bundleHeap.Unknown3 = reader.ReadUInt32(); bundleHeap.Type = (Data.BundleHeapType)reader.ReadUInt8(); bundleHeap.Unknown4 = reader.ReadUInt32(); bundleHeap.Unknown5 = reader.ReadBoolean(); bundleHeap.Unknown6 = reader.ReadUInt8(); bundleHeap.Unknown7 = reader.ReadUInt8(); bundleHeap.Unknown8 = reader.ReadUInt32(); if (saveVersion < 17) { reader.SkipBoolean(); } this._BundleHeaps.Add(bundleHeap); reader.PopFrameLength(); } var unknown3Count = reader.ReadUInt16(12); this._Unknown2.Clear(); for (int i = 0; i < unknown3Count; i++) { reader.PushFrameLength(24); var instance = new Data.SaveDataUnknown0(); instance.Unknown1 = reader.ReadUInt16(); instance.Unknown2 = reader.ReadUInt16(); instance.Unknown3 = reader.ReadUInt8(); this._Unknown2.Add(instance); reader.PopFrameLength(); } // not actually a Guid, but we will borrow it for sake of simplicity this._LevelHash = reader.ReadGuid(); var unknown5 = reader.ReadUInt32(20); if (unknown5 != 0) { throw new NotImplementedException(); } reader.SkipBits((int)unknown5); // TODO(gibbed): position move this._Unknown3 = reader.ReadUInt16(); this._Unknown4 = this._Unknown3 >= 5 ? reader.ReadUInt16() : (ushort)0; this._Unknown5 = reader.ReadBoolean(); reader.PushFramePosition(26); var componentDataPosition = reader.ReadUInt32(26); var entityBulkDataLength = reader.ReadUInt32(); var entityBulkDataPosition = reader.Position; reader.SkipBits((int)entityBulkDataLength); var unknown9 = reader.Position; reader.PushFrameLength(saveVersion >= 18 ? 24 : 6); reader.PushFrameLength(24); this._Unknown6 = reader.ReadString(); this._Unknown7 = reader.ReadString(); this._SaveName = reader.ReadString(); reader.PopFrameLength(); this._Unknown8 = reader.ReadUInt32(); this._Unknown9 = reader.ReadGuid(); this._Unknown10 = reader.ReadUInt32(); reader.PopFrameLength(); var unknown16 = reader.ReadUInt32(26); if (unknown9 != unknown16) { throw new FormatException(); } var agentBulkDataLength = reader.ReadUInt32(); var agentBulkDataPosition = reader.Position; reader.SkipBits((int)agentBulkDataLength); var agentDataCount = reader.ReadUInt8(4); var agentDataOffsetLookup = new Dictionary <byte, uint[]>(); for (int i = 0; i < agentDataCount; i++) { var index = reader.ReadUInt8(); var agentDataOffsets = new uint[5]; for (int j = 0; j < 5; j++) { var agentDataOffset = agentDataOffsets[j] = reader.ReadUInt32(26); if (agentDataOffset != 0) { if (agentDataOffset < agentBulkDataPosition || agentDataOffset > agentBulkDataPosition + agentBulkDataLength) { throw new FormatException(); } } } agentDataOffsetLookup.Add(index, agentDataOffsets); } reader.PushFrameLength(24); var entityDataCount = reader.ReadUInt16(); var entityDataOffsets = new Dictionary <uint, Tuple <uint?, uint?> >(); for (int i = 0; i < entityDataCount; i++) { var entityId = reader.ReadUInt32(); uint?entityData0Offset = null; uint?entityData1Offset = null; var entityHasData0 = reader.ReadBoolean(); if (entityHasData0 == true) { var entityDataOffset = reader.ReadUInt32(26); if (entityDataOffset < entityBulkDataPosition || entityDataOffset > entityBulkDataPosition + entityBulkDataLength) { throw new FormatException(); } entityData0Offset = entityDataOffset; } var entityHasData1 = reader.ReadBoolean(); if (entityHasData1 == true) { var entityDataOffset = reader.ReadUInt32(26); if (entityDataOffset < entityBulkDataPosition || entityDataOffset > entityBulkDataPosition + entityBulkDataLength) { throw new FormatException(); } entityData1Offset = entityDataOffset; } entityDataOffsets.Add(entityId, new Tuple <uint?, uint?>(entityData0Offset, entityData1Offset)); } var unknown17Count = reader.ReadUInt16(); this._Unknown11.Clear(); for (int i = 0; i < unknown17Count; i++) { this._Unknown11.Add(reader.ReadUInt32()); } var unknown18Count = reader.ReadUInt16(); for (int i = 0; i < unknown18Count; i++) { reader.PushFrameLength(24); var unknown19 = reader.ReadUInt32(); var unknown20Count = reader.ReadUInt16(); var unknown20 = new uint[unknown20Count]; for (int j = 0; j < unknown20Count; j++) { unknown20[j] = reader.ReadUInt32(); } reader.PopFrameLength(); throw new NotImplementedException(); } var unknown12Count = reader.ReadUInt16(); this._Unknown12.Clear(); for (int i = 0; i < unknown12Count; i++) { this._Unknown12.Add(reader.ReadUInt32()); } reader.PopFrameLength(); reader.PopFramePosition(); reader.PushFrameLength(24); var agentCount = reader.ReadUInt8(4); this._Agents.Clear(); for (int i = 0; i < agentCount; i++) { var nameHash = reader.ReadUInt32(); var index = reader.ReadUInt8(); var agent = AgentFactory.Create(nameHash); agent.Read0(reader, index); this._Agents.Add(index, agent); } reader.PopFrameLength(); if (reader.FrameCount != 0) { throw new SaveFormatException(); } if (reader.Position != componentDataPosition) { throw new SaveFormatException(); } reader.PushFrameLength(32); this._ComponentContainerAgents.Clear(); this._Unknown13 = reader.ReadUInt16(); if (this._Unknown13 == 1) { var componentCount = reader.ReadUInt16(); for (int i = 0; i < componentCount; i++) { reader.PushFrameLength(24); var componentNameHash = reader.ReadUInt32(); var componentVersion = reader.ReadUInt16(); var component = ComponentContainerAgentFactory.Create(componentNameHash); component.Read(reader, componentVersion); reader.PopFrameLength(); this._ComponentContainerAgents.Add(component); } } reader.PopFrameLength(); ReadAgentData(reader, this._Agents, agentDataOffsetLookup, 0, (r, t) => t.Read1(r, this._Unknown4)); ReadAgentData(reader, this._Agents, agentDataOffsetLookup, 1, (r, t) => t.Read2(r)); ReadAgentData(reader, this._Agents, agentDataOffsetLookup, 2, (r, t) => t.Read3(r, this._Unknown4)); ReadAgentData(reader, this._Agents, agentDataOffsetLookup, 3, (r, t) => t.Read4(r)); ReadAgentData(reader, this._Agents, agentDataOffsetLookup, 4, (r, t) => t.Read5(r)); /* * var entities = new List<Entities.Entity>(); * foreach (var kv in entityDataOffsets) * { * var entityDataFirstOffset = kv.Value.Item1; * var entityDataSecondOffset = kv.Value.Item2; * * var entity = Entities.EntityFactory.Create(kv.Key); * * if (entityDataFirstOffset.HasValue == true) * { * reader.Position = (int)entityDataFirstOffset.Value; * reader.PushFrameLength(24); * entity.Read0(reader); * reader.PopFrameLength(); * } * * if (entityDataSecondOffset.HasValue == true) * { * reader.Position = (int)entityDataSecondOffset.Value; * reader.PushFrameLength(24); * entity.Read1(reader); * reader.PopFrameLength(); * } * * entities.Add(entity); * } */ this._Entities.Clear(); foreach (var kv in entityDataOffsets) { var entityData0Offset = kv.Value.Item1; var entityData1Offset = kv.Value.Item2; var rawEntity = new Entities.RawEntity(); rawEntity.Id = kv.Key; if (entityData0Offset.HasValue == true) { reader.Position = (int)entityData0Offset.Value; rawEntity.Data0Length = (int)reader.ReadUInt32(24); rawEntity.Data0Bytes = reader.ReadBits(rawEntity.Data0Length); } if (entityData1Offset.HasValue == true) { reader.Position = (int)entityData1Offset.Value; rawEntity.Data1Length = (int)reader.ReadUInt32(24); rawEntity.Data1Bytes = reader.ReadBits(rawEntity.Data1Length); } this._Entities.Add(rawEntity); } if (reader.FrameCount != 0) { throw new SaveFormatException(); } if (reader.HasUnreadBits() == true) { throw new SaveFormatException(); } }
internal void Read(IBitReader reader) { this._Bools.Clear(); this._Ints.Clear(); this._Floats.Clear(); this._Transforms.Clear(); this._Unknown.Clear(); reader.PushFrameLength(24); var version = reader.ReadUInt16(); if (version >= 2) { var marker = reader.ReadString(); if (marker != "BioMetrics_PlotStartMarker") { throw new SaveFormatException(); } } if (version >= 1) { var falseCount = reader.ReadUInt32(version >= 4 ? 31 : 16); for (int i = 0; i < falseCount; i++) { var key = reader.ReadGuid(); this._Bools.Add(key, false); } var trueCount = reader.ReadUInt32(version >= 4 ? 31 : 16); for (int i = 0; i < trueCount; i++) { var key = reader.ReadGuid(); this._Bools.Add(key, true); } var intCount = reader.ReadUInt16(); for (int i = 0; i < intCount; i++) { var key = reader.ReadGuid(); var value = reader.ReadInt32(); this._Ints.Add(key, value); } var floatCount = reader.ReadUInt16(); for (int i = 0; i < floatCount; i++) { var key = reader.ReadGuid(); var value = reader.ReadFloat32(); this._Floats.Add(key, value); } var transformCount = reader.ReadUInt16(); for (int i = 0; i < transformCount; i++) { var key = reader.ReadGuid(); var value = reader.ReadTransform(); this._Transforms.Add(key, value); } } if (version >= 3) { var unknownCount = reader.ReadUInt16(); for (int i = 0; i < unknownCount; i++) { reader.PushFrameLength(24); var key = reader.ReadUInt32(); var value = reader.ReadGuid(); reader.PopFrameLength(); this._Unknown.Add(key, value); } } reader.PopFrameLength(); }
internal void Read(IBitReader reader, ushort version) { this._Unknown.Clear(); if (version < 2) { var unknownCount = reader.ReadUInt32(); var types = new NotificationsType[unknownCount]; for (uint i = 0; i < unknownCount; i++) { types[i] = (NotificationsType)reader.ReadUInt32(); } for (uint i = 0; i < unknownCount; i++) { var unknown = new NotificationsUnknown6(); unknown.Type = types[i]; unknown.Unknown1 = reader.ReadUInt8(); unknown.Unknown2 = null; this._Unknown.Add(unknown); } } else if (version < 3) { var unknownCount = reader.ReadUInt32(); for (uint i = 0; i < unknownCount; i++) { var unknown = new NotificationsUnknown6(); unknown.Type = (NotificationsType)reader.ReadUInt32(); switch (unknown.Type) { case NotificationsType.Unknown0: case NotificationsType.Unknown1: { unknown.Unknown1 = reader.ReadUInt32(); break; } case NotificationsType.Unknown2: { unknown.Unknown2 = reader.ReadString(); break; } default: { throw new FormatException(); } } this._Unknown.Add(unknown); } } else { var unknownCount = reader.ReadUInt16(); for (uint i = 0; i < unknownCount; i++) { reader.PushFrameLength(24); var unknown = new NotificationsUnknown6(); unknown.Type = (NotificationsType)reader.ReadUInt32(); switch (unknown.Type) { case NotificationsType.Unknown0: case NotificationsType.Unknown1: { unknown.Unknown1 = reader.ReadUInt32(); break; } case NotificationsType.Unknown2: { unknown.Unknown2 = reader.ReadString(); break; } default: { throw new FormatException(); } } this._Unknown.Add(unknown); reader.PopFrameLength(); } } }
public virtual void Read(IBitReader reader, ushort version) { this._ComponentContainers.Clear(); if (version == 2) { var componentContainerVersion = reader.ReadUInt16(); reader.PushFrameLength(24); var componentContainerCount = reader.ReadUInt16(); for (int i = 0; i < componentContainerCount; i++) { reader.PushFrameLength(24); var componentContainerId = reader.ReadUInt32(); ComponentContainer componentContainer = null; var hasComponents = reader.ReadBoolean(); if (hasComponents == true) { componentContainer = new ComponentContainer(); if (componentContainerVersion >= 2) { componentContainer.Unknown1 = reader.ReadBoolean(); } if (componentContainerVersion >= 3) { componentContainer.Unknown2 = reader.ReadString(); } var componentCount = reader.ReadUInt16(); for (int j = 0; j < componentCount; j++) { reader.PushFrameLength(24); var componentNameHash = reader.ReadUInt32(); var component = ComponentFactory.Create(componentNameHash); if (component == null) { throw new InvalidOperationException(); } component.Read(reader, componentContainerVersion); componentContainer.Components.Add(component); reader.PopFrameLength(); } } this._ComponentContainers.Add(componentContainerId, componentContainer); reader.PopFrameLength(); } reader.PopFrameLength(); } }