コード例 #1
0
ファイル: TrophyTrp.cs プロジェクト: asker1982/HyoutaTools
        public TrophyTrp(HyoutaPluginBase.DuplicatableStream stream, EndianUtils.Endianness endian = EndianUtils.Endianness.BigEndian)
        {
            Stream = stream.Duplicate();
            Endian = endian;
            try {
                Stream.ReStart();
                Magic = Stream.ReadUInt32().FromEndian(EndianUtils.Endianness.LittleEndian);
                if (Magic != 0x004DA2DC)
                {
                    throw new Exception("invalid magic");
                }
                Unknown2 = Stream.ReadUInt32().FromEndian(endian);
                Unknown3 = Stream.ReadUInt32().FromEndian(endian);
                Filesize = Stream.ReadUInt32().FromEndian(endian);

                Filecount = Stream.ReadUInt32().FromEndian(endian);
                Unknown6  = Stream.ReadUInt32().FromEndian(endian);
                Unknown7  = Stream.ReadUInt32().FromEndian(endian);
                Unknown8  = Stream.ReadUInt32().FromEndian(endian);

                Unknown9  = Stream.ReadUInt32().FromEndian(endian);
                Unknown10 = Stream.ReadUInt32().FromEndian(endian);
                Unknown11 = Stream.ReadUInt32().FromEndian(endian);
                Unknown12 = Stream.ReadUInt32().FromEndian(endian);

                Unknown13 = Stream.ReadUInt32().FromEndian(endian);
                Unknown14 = Stream.ReadUInt32().FromEndian(endian);
                Unknown15 = Stream.ReadUInt32().FromEndian(endian);
                Unknown16 = Stream.ReadUInt32().FromEndian(endian);
            } finally {
                Stream.End();
            }
        }
コード例 #2
0
ファイル: SaveData.cs プロジェクト: asker1982/HyoutaTools
 private static void ExportSingle(HyoutaPluginBase.DuplicatableStream stream, string path)
 {
     if (stream != null)
     {
         using (var s = stream.Duplicate())
             using (var f = new FileStream(path, FileMode.Create)) {
                 StreamUtils.CopyStream(s, f, s.Length);
             }
     }
 }
コード例 #3
0
ファイル: ScenarioDat.cs プロジェクト: asker1982/HyoutaTools
        public ScenarioDat(HyoutaPluginBase.DuplicatableStream data)
        {
            Magic    = data.ReadAscii(8);
            Filesize = data.ReadUInt32().SwapEndian();
            Unknown  = data.ReadUInt32().SwapEndian();

            Filecount   = data.ReadUInt32().SwapEndian();
            FilesOffset = data.ReadUInt32().SwapEndian();
            uint FilesizeAgain = data.ReadUInt32();
            uint Padding       = data.ReadUInt32();

            Entries = new List <ScenarioDatEntry>((int)Filecount);
            for (uint i = 0; i < Filecount; ++i)
            {
                data.Position = 0x20u + i * 0x20u;
                var e = new ScenarioDatEntry(data, FilesOffset);
                Entries.Add(e);
            }
        }
コード例 #4
0
ファイル: SaveData.cs プロジェクト: asker1982/HyoutaTools
        public SaveData(HyoutaPluginBase.DuplicatableStream stream, EndianUtils.Endianness endian)
        {
            MenuBlock = new SaveMenuBlock(new PartialStream(stream, 0, 0x228));

            // actual save file
            using (DuplicatableStream saveDataStream = new PartialStream(stream, 0x228, stream.Length - 0x228)) {
                string magic = saveDataStream.ReadAscii(8);
                if (magic != "TO8SAVE\0")
                {
                    throw new Exception("Invalid magic byte sequence for ToV save: " + magic);
                }
                uint saveFileSize = saveDataStream.ReadUInt32().FromEndian(endian);
                saveDataStream.DiscardBytes(0x14);                   // seemingly unused
                uint sectionMetadataBlockStart = saveDataStream.ReadUInt32().FromEndian(endian);
                uint sectionCount   = saveDataStream.ReadUInt32().FromEndian(endian);
                uint dataStart      = saveDataStream.ReadUInt32().FromEndian(endian);
                uint refStringStart = saveDataStream.ReadUInt32().FromEndian(endian);

                for (uint i = 0; i < sectionCount; ++i)
                {
                    uint headerPosition = sectionMetadataBlockStart + i * 0x20;
                    saveDataStream.Position = headerPosition;
                    uint   refStringPos = saveDataStream.ReadUInt32().FromEndian(endian);
                    uint   offset       = saveDataStream.ReadUInt32().FromEndian(endian);
                    uint   size         = saveDataStream.ReadUInt32().FromEndian(endian);
                    var    blockStream  = new PartialStream(saveDataStream, dataStart + offset, size);
                    string blockName    = saveDataStream.ReadAsciiNulltermFromLocationAndReset(refStringStart + refStringPos);

                    if (blockName.StartsWith("PC_STATUS"))
                    {
                        int idx = int.Parse(blockName.Substring("PC_STATUS".Length)) - 1;
                        CharacterData[idx] = new SaveDataBlockPCStatus(blockStream);
                    }
                    else
                    {
                        switch (blockName)
                        {
                        case "Scenario": Scenario = new SaveDataBlockScenario(blockStream); break;

                        case "FieldCamera": FieldCamera = new SaveDataBlockFieldCamera(blockStream); break;

                        case "FieldArea": FieldArea = new SaveDataBlockFieldArea(blockStream); break;

                        case "FieldCar": FieldCar = new SaveDataBlockFieldCar(blockStream); break;

                        case "Camp": Camp = new SaveDataBlockCamp(blockStream); break;

                        case "FIELD_SAVE": FieldSave = new SaveDataBlockFieldSave(blockStream); break;

                        case "STANDBYENEMY": StandbyEnemy = new SaveDataBlockStandbyEnemy(blockStream); break;

                        case "TERASURE_SAVE": TerasureSave = new SaveDataBlockTerasureSave(blockStream); break;

                        case "TreasureSaveData": TreasureSaveData = new SaveDataBlockTreasureSaveData(blockStream); break;

                        case "CUSTOM_DATA": CustomData = new SaveDataBlockCustomData(blockStream); break;

                        case "SoundTheater": SoundTheater = new SaveDataBlockSoundTheater(blockStream); break;

                        case "SavePoint": SavePoint = new SaveDataBlockSavePoint(blockStream); break;

                        case "MG2Poker": MG2Poker = new SaveDataBlockMG2Poker(blockStream); break;

                        case "SnowBoard": SnowBoard = new SaveDataBlockSnowBoard(blockStream); break;

                        case "PARTY_DATA": PartyData = new SaveDataBlockPartyData(blockStream); break;

                        case "FieldGadget": FieldGadget = new SaveDataBlockFieldGadget(blockStream); break;

                        default: Console.WriteLine("Unknown save data block '" + blockName + "'"); break;
                        }
                    }
                }
            }
        }