public void Read(PsoDataReader reader) { int x1 = reader.ReadInt32(); int x2 = reader.ReadInt32(); if (x2 != 0) { throw new Exception("zero_Ch should be 0"); } var BlockIndex = (int)(x1 & 0x00000FFF); var Offset = (int)((x1 & 0xFFFFF000) >> 12); // read reference data... var backupOfSection = reader.CurrentSectionIndex; var backupOfPosition = reader.Position; reader.SetSectionIndex(BlockIndex - 1); reader.Position = Offset; Value = reader.ReadString(); reader.SetSectionIndex(backupOfSection); reader.Position = backupOfPosition; }
public void Read(PsoDataReader reader) { int x1 = reader.ReadInt32(); int x2 = reader.ReadInt32(); int x3 = reader.ReadInt32(); int unk = (x3 >> 12) & 0x000FFFFF; int sectionIndex = x3 & 0x00000FFF; int x4 = reader.ReadInt32(); int x5 = reader.ReadInt32(); int length1 = (x5 >> 16) & 0x0000FFFF; int length2 = x5 & 0x0000FFFF; if (length1 != length2) { throw new Exception("length does not match"); } int x6 = reader.ReadInt32(); // read reference data... var backupOfSection = reader.CurrentSectionIndex; var backupOfPosition = reader.Position; reader.SetSectionIndex(sectionIndex - 1); reader.Position = unk; int nameOfDataSection = pso.DataMappingSection.Entries[sectionIndex - 1].NameHash; var sectionInfo = (PsoStructureInfo)null; //var sectionIdxInfo = (PsoElementIndexInfo)null; for (int k = 0; k < pso.DefinitionSection.EntriesIdx.Count; k++) { if (pso.DefinitionSection.EntriesIdx[k].NameHash == nameOfDataSection) { sectionInfo = (PsoStructureInfo)pso.DefinitionSection.Entries[k]; //sectionIdxInfo = pso.DefinitionSection.EntriesIdx[k]; } } Entries = new List <PsoStructure>(); for (int i = 0; i < length1; i++) { var entryStr = new PsoStructure(pso, sectionInfo, null, null); entryStr.Read(reader); Entries.Add(entryStr); } reader.SetSectionIndex(backupOfSection); reader.Position = backupOfPosition; }
public void Read(PsoDataReader reader) { var blockIndexAndOffset = reader.ReadUInt32(); var BlockIndex = (int)(blockIndexAndOffset & 0x00000FFF); var Offset = (int)((blockIndexAndOffset & 0xFFFFF000) >> 12); var zero_4h = reader.ReadUInt32(); if (zero_4h != 0) { throw new Exception("zero_4h should be 0"); } var size1 = reader.ReadUInt16(); var size2 = reader.ReadUInt16(); if (size1 != size2) { throw new Exception("size1 should be size2"); } var NumberOfEntries = size1; var zero_Ch = reader.ReadUInt32(); if (zero_Ch != 0) { throw new Exception("zero_Ch should be 0"); } if (BlockIndex > 0) { // read reference data... var backupOfSection = reader.CurrentSectionIndex; var backupOfPosition = reader.Position; reader.SetSectionIndex(BlockIndex - 1); reader.Position = Offset; Entries = new List <IPsoValue>(); for (int i = 0; i < NumberOfEntries; i++) { var entry = PsoTypeBuilder.Make(pso, structureInfo, entryInfo); entry.Read(reader); Entries.Add(entry); } reader.SetSectionIndex(backupOfSection); reader.Position = backupOfPosition; } else { Entries = null; } }
public void Read(PsoDataReader reader) { var blockIndexAndOffset = reader.ReadUInt32(); var BlockIndex = (int)(blockIndexAndOffset & 0x00000FFF); var Offset = (int)((blockIndexAndOffset & 0xFFFFF000) >> 12); var zero_4h = reader.ReadUInt32(); if (zero_4h != 0) { throw new Exception("zero_4h should be 0"); } var size1 = reader.ReadUInt16() & 0x0FFF; var size2 = reader.ReadUInt16() & 0x0FFF; //if (size1 != size2 - 1) //{ // throw new Exception("size1 should be size2"); //} var NumberOfEntries = size2; var zero_Ch = reader.ReadUInt32(); if (zero_Ch != 0) { throw new Exception("zero_Ch should be 0"); } // read reference data... if (BlockIndex > 0) { var backupOfSection = reader.CurrentSectionIndex; var backupOfPosition = reader.Position; reader.SetSectionIndex(BlockIndex - 1); reader.Position = Offset; string s = ""; for (int k = 0; k < NumberOfEntries; k++) { s += (char)reader.ReadByte(); } Value = s; reader.SetSectionIndex(backupOfSection); reader.Position = backupOfPosition; } else { Value = null; } }
public IPsoValue Parse(PsoFile meta) { var blockKeys = new List <int>(); var blocks = new List <List <IPsoValue> >(); var t1 = (PsoStructureInfo)null; var t2 = (PsoElementIndexInfo)null; var rootHash = meta.DataMappingSection.Entries[meta.DataMappingSection.RootIndex - 1].NameHash; for (int i = 0; i < meta.DefinitionSection.Count; i++) { if (meta.DefinitionSection.EntriesIdx[i].NameHash == rootHash) { t1 = (PsoStructureInfo)meta.DefinitionSection.Entries[i]; t2 = meta.DefinitionSection.EntriesIdx[i]; } } var resultStructure = new PsoStructure(meta, t1, t2, null); var reader = new PsoDataReader(meta); reader.SetSectionIndex(meta.DataMappingSection.RootIndex - 1); reader.Position = 0; resultStructure.Read(reader); return(resultStructure); }
public void Read(PsoDataReader reader) { int z1 = reader.ReadInt32(); int z2 = reader.ReadInt32(); if (z2 != 0) { throw new Exception("z2 should be zero"); } int offset = (z1 >> 12) & 0x000FFFFF; int sectionIndex = z1 & 0x00000FFF; if (sectionIndex > 0) { var nameHash = pso.DataMappingSection.Entries[sectionIndex - 1].NameHash; var strInfo = (PsoStructureInfo)null; var sectionIdxInfo = (PsoElementIndexInfo)null; for (int k = 0; k < pso.DefinitionSection.Entries.Count; k++) { if (pso.DefinitionSection.EntriesIdx[k].NameHash == nameHash) { strInfo = (PsoStructureInfo)pso.DefinitionSection.Entries[k]; sectionIdxInfo = pso.DefinitionSection.EntriesIdx[k]; } } // read reference data... var backupOfSection = reader.CurrentSectionIndex; var backupOfPosition = reader.Position; reader.SetSectionIndex(sectionIndex - 1); reader.Position = offset; Value = new PsoStructure(pso, strInfo, sectionIdxInfo, null); Value.Read(reader); reader.SetSectionIndex(backupOfSection); reader.Position = backupOfPosition; } else { Value = null; } }