コード例 #1
0
ファイル: PsoFloat4B.cs プロジェクト: xchgrbprsp/gta-toolkit
 public void Read(PsoDataReader reader)
 {
     this.X = reader.ReadSingle();
     this.Y = reader.ReadSingle();
     this.Z = reader.ReadSingle();
     this.W = reader.ReadSingle();
 }
コード例 #2
0
ファイル: PsoReader.cs プロジェクト: xchgrbprsp/gta-toolkit
        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);
        }
コード例 #3
0
 public void Read(PsoDataReader reader)
 {
     var x1 = reader.ReadSingle();
     var x2 = reader.ReadSingle();
     var x3 = reader.ReadSingle();
     var x4 = reader.ReadSingle();
 }
コード例 #4
0
        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;
        }
コード例 #5
0
 public void Read(PsoDataReader reader)
 {
     X = reader.ReadSingle();
     Y = reader.ReadSingle();
     Z = reader.ReadSingle();
     W = reader.ReadSingle();
 }
コード例 #6
0
ファイル: PsoString8.cs プロジェクト: xchgrbprsp/gta-toolkit
        public void Read(PsoDataReader reader)
        {
            int z1 = reader.ReadInt32();
            int z2 = reader.ReadInt32();

            Value = z1;
        }
コード例 #7
0
ファイル: PsoArray4.cs プロジェクト: xchgrbprsp/gta-toolkit
 public void Read(PsoDataReader reader)
 {
     Entries = new List <IPsoValue>();
     for (int i = 0; i < numberOfEntries; i++)
     {
         var entry = PsoTypeBuilder.Make(pso, structureInfo, entryInfo);
         entry.Read(reader);
         Entries.Add(entry);
     }
 }
コード例 #8
0
ファイル: PsoMap.cs プロジェクト: xchgrbprsp/gta-toolkit
        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;
        }
コード例 #9
0
ファイル: PsoArray0.cs プロジェクト: xchgrbprsp/gta-toolkit
        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;
            }
        }
コード例 #10
0
ファイル: PsoString3.cs プロジェクト: xchgrbprsp/gta-toolkit
        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;
            }
        }
コード例 #11
0
        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;
            }
        }
コード例 #12
0
        public void Read(PsoDataReader reader)
        {
            Value = "";
            bool isok = true;

            for (int i = 0; i < length; i++)
            {
                char c = (char)reader.ReadByte();
                if (c == 0)
                {
                    isok = false;
                }
                else
                {
                    if (!isok)
                    {
                        throw new Exception("Unexpected char.");
                    }
                    Value += c;
                }
            }
        }
コード例 #13
0
        public void Read(PsoDataReader reader)
        {
            long backupOfPosition = reader.Position;

            this.Values = new Dictionary <int, IPsoValue>();
            for (int i = 0; i < structureInfo.Entries.Count; i++)
            {
                // skip unnamed entries...
                var x1 = structureInfo.Entries[i];
                if (x1.EntryNameHash == 0x100)
                {
                    continue;
                }


                reader.Position = backupOfPosition + x1.DataOffset;
                var value = PsoTypeBuilder.Make(pso, structureInfo, x1);
                value.Read(reader);
                Values.Add(x1.EntryNameHash, value);
            }

            reader.Position = backupOfPosition + structureInfo.StructureLength;
        }
コード例 #14
0
 public void Read(PsoDataReader reader)
 {
     Value = reader.ReadInt16();
 }
コード例 #15
0
ファイル: PsoXXByte.cs プロジェクト: xchgrbprsp/gta-toolkit
 public void Read(PsoDataReader reader)
 {
     Value = reader.ReadByte();
 }
コード例 #16
0
 public void Read(PsoDataReader reader)
 {
     this.Value = reader.ReadUInt32();
 }
コード例 #17
0
ファイル: PsoFloat.cs プロジェクト: xchgrbprsp/gta-toolkit
 public void Read(PsoDataReader reader)
 {
     Value = reader.ReadSingle();
 }