예제 #1
0
        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;
        }
예제 #2
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;
            }
        }
예제 #3
0
        public void Read(DataReader reader)
        {
            long position = reader.Position;

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

                reader.Position = position + x1.DataOffset;
                switch (x1.Type)
                {
                case DataType.Array:
                {
                    var entryValue = new PsoArray();
                    entryValue.psoSection = psoSection.Entries[x1.ReferenceKey & 0x0000FFFF];
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.INT_0Bh:
                {
                    if (psoSection.Entries[i].ReferenceKey == 0)
                    {
                        var entryValue = new PsoType11(0);
                        entryValue.Read(reader);
                        this.Values.Add(x1.EntryNameHash, entryValue);
                    }
                    else
                    {
                        var entryValue = new PsoType11(64);
                        entryValue.Read(reader);
                        this.Values.Add(x1.EntryNameHash, entryValue);
                    }

                    break;
                }

                case DataType.BYTE_ENUM_VALUE:
                {
                    var entryValue = new PsoType14();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.SHORT_0Fh:
                {
                    var entryValue = new PsoType15();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.INT_06h:
                {
                    var entryValue = new PsoType6();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.Structure:
                {
                    var entryValue = new PsoStructure();
                    entryValue.pso          = pso;
                    entryValue.psoSection   = GetStructureInfo(pso, x1.ReferenceKey);
                    entryValue.psoEntryInfo = GetStructureIndexInfo(pso, x1.ReferenceKey);
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }


                case DataType.TYPE_10h:
                {
                    var entryValue = new PsoType16();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.INT_05h:
                {
                    var entryValue = new PsoType5();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.BYTE_02h:
                {
                    var entryValue = new PsoType2();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.Float:
                {
                    var entryValue = new PsoFloat();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.BYTE_00h:
                {
                    var entryValue = new PsoType0();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                case DataType.TYPE_15h:
                {
                    var entryValue = new PsoType21();
                    entryValue.Read(reader);
                    this.Values.Add(x1.EntryNameHash, entryValue);
                    break;
                }

                default:
                    throw new Exception("Unknown Type");
                }
            }

            reader.Position = position + psoSection.StructureLength;
        }