Beispiel #1
0
        /// <summary>
        /// Deserializes file data from a stream.
        /// </summary>
        protected override void Read(BinaryReaderEx br)
        {
            br.BigEndian = false;

            Entries entries = default;

            int nextSectionOffset = (int)br.Position;

            do
            {
                br.Position = nextSectionOffset;

                int    unk1       = br.ReadInt32();
                int    typeOffset = br.ReadInt32();
                int    offsets    = br.ReadInt32() - 1;
                string type       = br.GetASCII(typeOffset);

                switch (type)
                {
                case "MODEL_PARAM_ST":
                    Models         = new ModelSection(br, unk1);
                    entries.Models = Models.Read(br, offsets);
                    break;

                //case "EVENT_PARAM_ST":
                //    Events = new EventSection(br, unk1);
                //    entries.Events = Events.Read(br, offsets);
                //    break;

                //case "POINT_PARAM_ST":
                //    Regions = new PointSection(br, unk1);
                //    entries.Regions = Regions.Read(br, offsets);
                //    break;

                case "PARTS_PARAM_ST":
                    Parts         = new PartsSection(br, unk1);
                    entries.Parts = Parts.Read(br, offsets);
                    break;

                //case "MAPSTUDIO_TREE_ST":
                //    Trees = new TreeSection(br, unk1);
                //    entries.Trees = Trees.Read(br, offsets);
                //    break;

                default:
                    //throw new NotImplementedException($"Unimplemented section: {type}");
                    br.Skip(offsets * 4);
                    break;
                }

                nextSectionOffset = br.ReadInt32();
            } while (nextSectionOffset != 0);

            //DisambiguateNames(entries.Events);
            MSB.DisambiguateNames(entries.Models);
            MSB.DisambiguateNames(entries.Parts);
            //DisambiguateNames(entries.Regions);

            //Events.GetNames(this, entries);
            Parts.GetNames(this, entries);
            //Regions.GetNames(this, entries);
        }
Beispiel #2
0
        internal override void Read(BinaryReaderEx br)
        {
            br.BigEndian = false;

            br.AssertASCII("MSB ");
            br.AssertInt32(1);
            // Header size/data start
            br.AssertInt32(0x10);

            // Probably bytes, just guessing
            br.AssertByte(0);
            br.AssertByte(0);
            br.AssertByte(1);
            br.AssertByte(0xFF);

            Entries entries = default;

            long nextSectionOffset = br.Position;

            while (nextSectionOffset != 0)
            {
                br.Position = nextSectionOffset;

                int    unk1       = br.ReadInt32();
                int    offsets    = br.ReadInt32() - 1;
                long   typeOffset = br.ReadInt64();
                string type       = br.GetUTF16(typeOffset);

                switch (type)
                {
                case "MODEL_PARAM_ST":
                    Models         = new ModelSection(br, unk1);
                    entries.Models = Models.Read(br, offsets);
                    break;

                case "EVENT_PARAM_ST":
                    Events         = new EventSection(br, unk1);
                    entries.Events = Events.Read(br, offsets);
                    break;

                case "POINT_PARAM_ST":
                    Regions         = new PointSection(br, unk1);
                    entries.Regions = Regions.Read(br, offsets);
                    break;

                case "ROUTE_PARAM_ST":
                    Routes         = new RouteSection(br, unk1);
                    entries.Routes = Routes.Read(br, offsets);
                    break;

                case "LAYER_PARAM_ST":
                    Layers         = new LayerSection(br, unk1);
                    entries.Layers = Layers.Read(br, offsets);
                    break;

                case "PARTS_PARAM_ST":
                    Parts         = new PartsSection(br, unk1);
                    entries.Parts = Parts.Read(br, offsets);
                    break;

                case "MAPSTUDIO_PARTS_POSE_ST":
                    PartsPoses = new PartsPoseSection(br, unk1, offsets);
                    break;

                case "MAPSTUDIO_BONE_NAME_STRING":
                    BoneNames         = new BoneNameSection(br, unk1);
                    entries.BoneNames = BoneNames.Read(br, offsets);
                    break;

                default:
                    throw new NotImplementedException($"Unimplemented section: {type}");
                }

                nextSectionOffset = br.ReadInt64();
            }

            DisambiguateNames(entries.Events);
            DisambiguateNames(entries.Models);
            DisambiguateNames(entries.Parts);
            DisambiguateNames(entries.Regions);

            Events.GetNames(this, entries);
            Parts.GetNames(this, entries);
            Regions.GetNames(this, entries);
        }