Beispiel #1
0
                private string CutsceneName; // For debugging

                public void ReadFromFile(BinaryReader reader, string name)
                {
                    CutsceneName = name;

                    int magic = reader.ReadInt32();

                    if (magic == 1000)
                    {
                        //the size includes the size and the magic, A.K.A: (magic and size == 8)
                        Size = reader.ReadUInt32();

                        int fourcc = reader.ReadInt32();
                        if (fourcc == 0x21445053)
                        {
                            Unk01 = reader.ReadInt32();
                            Unk02 = reader.ReadSingle();
                            int NumEntities = reader.ReadInt32();
                            EntityDefinitions = new AnimEntityWrapper[NumEntities];

                            for (int i = 0; i < NumEntities; i++)
                            {
                                int Header = reader.ReadInt32();
                                Debug.Assert(Header == 126, "We've missed the entity definition Magic!"); // Or 0x7F

                                int             Size = reader.ReadInt32();
                                int             RawAnimEntityType = reader.ReadInt32();
                                AnimEntityTypes AnimEntityType    = (AnimEntityTypes)RawAnimEntityType;

                                byte[] DefintionData = reader.ReadBytes(Size - 12);
                                using (MemoryStream Reader = new MemoryStream(DefintionData))
                                {
                                    AnimEntityWrapper Entity = CutsceneEntityFactory.ReadAnimEntityWrapperFromFile(AnimEntityType, Reader);

                                    // Debugging: If the AnimEntity is null and a debugger is attached, we should save it to the disc.
                                    string format = string.Format("CutsceneInfo/{0}/Entity_SPD_{1}_{2}.bin", CutsceneName, AnimEntityType, i);
                                    File.WriteAllBytes(format, DefintionData);

                                    EntityDefinitions[i] = Entity;
                                }
                            }

                            for (int z = 0; z < NumEntities; z++)
                            {
                                // Export this first
                                int dataType   = reader.ReadInt32();
                                int entitySize = reader.ReadInt32();
                                reader.BaseStream.Position -= 8;
                                byte[] dataBytes = reader.ReadBytes(entitySize);

                                string format = string.Format("CutsceneInfo/{2}/{0}_SPD_{1}.bin", EntityDefinitions[z], z, CutsceneName);
                                File.WriteAllBytes(format, dataBytes);

                                // And then This
                                using (MemoryStream stream = new MemoryStream(dataBytes))
                                {
                                    EntityDefinitions[z].AnimEntityData.ReadFromFile(stream, false);
                                }
                            }
                        }
                    }
                }
Beispiel #2
0
                public void ReadFromFile(BinaryReader reader, string name)
                {
                    CutsceneName = name;

                    header      = new string(reader.ReadChars(4));
                    unk02       = reader.ReadInt32();
                    unk03       = reader.ReadSingle();
                    unk04       = reader.ReadInt16();
                    unk05       = reader.ReadInt16();
                    unk06       = reader.ReadInt32();
                    unk07       = reader.ReadInt32();
                    unk08       = reader.ReadBytes(unk07 - 4);
                    unk09       = reader.ReadInt32();
                    numEntities = reader.ReadUInt16();
                    entities    = new AnimEntityWrapper[numEntities];

                    for (int i = 0; i < numEntities; i++)
                    {
                        int Header = reader.ReadInt32();
                        Debug.Assert(Header == 126, "We've missed the entity definition Magic!"); // Or 0x7F

                        int             Size = reader.ReadInt32();
                        int             RawAnimEntityType = reader.ReadInt32();
                        AnimEntityTypes AnimEntityType    = (AnimEntityTypes)RawAnimEntityType;

                        byte[] DefintionData = reader.ReadBytes(Size - 12);
                        using (MemoryStream Reader = new MemoryStream(DefintionData))
                        {
                            AnimEntityWrapper EntityWrapper = CutsceneEntityFactory.ReadAnimEntityWrapperFromFile(AnimEntityType, Reader);

                            string format = string.Format("CutsceneInfo/{2}/Entity_{0}_{1}.bin", AnimEntityType, i, CutsceneName);
                            File.WriteAllBytes(format, DefintionData);

                            entities[i] = EntityWrapper;
                        }
                    }

                    for (int z = 0; z < numEntities; z++)
                    {
                        // Export this first
                        int dataType = reader.ReadInt32();
                        int size     = reader.ReadInt32();
                        reader.BaseStream.Position -= 8;
                        byte[] dataBytes = reader.ReadBytes(size);

                        string format = string.Format("CutsceneInfo/{2}/{0}_{1}.bin", entities[z], z, CutsceneName);
                        File.WriteAllBytes(format, dataBytes);

                        // And then This
                        using (MemoryStream stream = new MemoryStream(dataBytes))
                        {
                            entities[z].AnimEntityData.ReadFromFile(stream, false);
                            Debug.Assert(stream.Position == stream.Length, "When reading the AnimEntity Data, we did not reach the end of the stream!");
                        }
                    }

                    unk10 = reader.ReadInt32();
                    unk11 = reader.ReadSingle();
                    unk12 = reader.ReadInt32();
                    unk13 = reader.ReadSingle();
                    unk14 = reader.ReadInt32();
                }