Ejemplo n.º 1
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public override void Serialize(IBinarySerializer s)
        {
            // Serialize header
            base.Serialize(s);

            // Serialize the file table
            if (s.IsReading)
            {
                var tempList = new List <Rayman1PCArchiveEntry>();

                while (!tempList.Any() || tempList.Last().FileName != "ENDFILE")
                {
                    tempList.Add(s.SerializeObject <Rayman1PCArchiveEntry>(null, name: $"{nameof(Files)}[{tempList.Count}]"));
                }

                Files = tempList.Take(tempList.Count - 1).ToArray();
            }
            else
            {
                s.SerializeObjectArray <Rayman1PCArchiveEntry>(Files, Files.Length, name: nameof(Files));
                s.SerializeObject <Rayman1PCArchiveEntry>(new Rayman1PCArchiveEntry()
                {
                    FileName = "ENDFILE"
                }, name: $"ENDFILE");
            }
        }
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Serialize the unknown value
            Unknown = s.Serialize <ushort>(Unknown, name: nameof(Unknown));

            // Serialize the level collection
            Levels = s.SerializeObjectArray <JungleRunPCSaveDataLevel>(Levels, 70, name: nameof(Levels));

            // Serialize remaining bytes
            RemainingBytes = s.SerializeArray <byte>(RemainingBytes, (int)(s.Stream.Length - s.Stream.Position), name: nameof(RemainingBytes));
        }
        public static T[] SerializeUbiArtObjectArray <T>(this IBinarySerializer s, T[] array, string name = null)
            where T : IBinarySerializable, new()
        {
            // Serialize the size
            array = s.SerializeArraySize <T, uint>(array, name: name);

            // Serialize the array
            array = s.SerializeObjectArray <T>(array, array.Length, name: name);

            // Return the array
            return(array);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            TotalCages = s.Serialize <int>(TotalCages, name: nameof(TotalCages));
            TotalScore = s.Serialize <int>(TotalScore, name: nameof(TotalScore));

            Levels = s.SerializeObjectArray <Rayman3PCSaveDataLevel>(Levels, 9, name: nameof(Levels));

            ForKeyAlgo       = s.Serialize <uint>(ForKeyAlgo, name: nameof(ForKeyAlgo));
            Dword_7FE504     = s.Serialize <uint>(Dword_7FE504, name: nameof(Dword_7FE504));
            Dword_7FE508     = s.Serialize <uint>(Dword_7FE508, name: nameof(Dword_7FE508));
            Dword_7FE50C     = s.Serialize <uint>(Dword_7FE50C, name: nameof(Dword_7FE50C));
            EndOfGameIsDone  = s.SerializeBool <uint>(EndOfGameIsDone, name: nameof(EndOfGameIsDone));
            MaxIndCurrentEnv = s.Serialize <uint>(MaxIndCurrentEnv, name: nameof(MaxIndCurrentEnv));
            UnusedDword1     = s.Serialize <uint>(UnusedDword1, name: nameof(UnusedDword1));
            UnusedDword2     = s.Serialize <uint>(UnusedDword2, name: nameof(UnusedDword2));

            DummyByte                    = s.Serialize <byte>(DummyByte, name: nameof(DummyByte));
            IsVibrationEnabled           = s.Serialize <bool>(IsVibrationEnabled, name: nameof(IsVibrationEnabled));
            IsHorizontalInversionEnabled = s.Serialize <bool>(IsHorizontalInversionEnabled, name: nameof(IsHorizontalInversionEnabled));
            IsVerticalInversionEnabled   = s.Serialize <bool>(IsVerticalInversionEnabled, name: nameof(IsVerticalInversionEnabled));

            KeyboardMapping   = s.SerializeArray <DirectXKey>(KeyboardMapping, 13, name: nameof(KeyboardMapping));
            ControllerMapping = s.SerializeArray <ushort>(ControllerMapping, 13, name: nameof(ControllerMapping));

            UserWarnedAboutAutoSave               = s.Serialize <int>(UserWarnedAboutAutoSave, name: nameof(UserWarnedAboutAutoSave));
            RevisitMode                           = s.Serialize <int>(RevisitMode, name: nameof(RevisitMode));
            RevisitEnvScoreAtBeginingOfLevel      = s.Serialize <int>(RevisitEnvScoreAtBeginingOfLevel, name: nameof(RevisitEnvScoreAtBeginingOfLevel));
            RevisitGlobalScoreAtBeginingOfLevel   = s.Serialize <int>(RevisitGlobalScoreAtBeginingOfLevel, name: nameof(RevisitGlobalScoreAtBeginingOfLevel));
            RevisitIndCurrentEnv                  = s.Serialize <int>(RevisitIndCurrentEnv, name: nameof(RevisitIndCurrentEnv));
            RevisitIndEnvironementFromWhereWeCome = s.Serialize <int>(RevisitIndEnvironementFromWhereWeCome, name: nameof(RevisitIndEnvironementFromWhereWeCome));

            LevelNameToSave            = s.SerializeString(LevelNameToSave, 20, LevelNameToSave);
            LevelNameAfterReinitToSave = s.SerializeString(LevelNameAfterReinitToSave, 20, LevelNameAfterReinitToSave);

            Unk1 = s.SerializeArray <byte>(Unk1, 16, name: nameof(Unk1));

            SetVolumeSound    = s.Serialize <int>(SetVolumeSound, name: nameof(SetVolumeSound));
            SetVolumeVoice    = s.Serialize <int>(SetVolumeVoice, name: nameof(SetVolumeVoice));
            SetVolumeMusic    = s.Serialize <int>(SetVolumeMusic, name: nameof(SetVolumeMusic));
            SetVolumeAmbiance = s.Serialize <int>(SetVolumeAmbiance, name: nameof(SetVolumeAmbiance));
            SetVolumeMenu     = s.Serialize <int>(SetVolumeMenu, name: nameof(SetVolumeMenu));

            if (s.IsReading)
            {
                var temp = new List <Rayman3PCSaveDataEntry>();

                var index = 0;

                while (temp.LastOrDefault()?.KeyLength != 0)
                {
                    temp.Add(s.SerializeObject <Rayman3PCSaveDataEntry>(default, name: $"{Items}[{index}]"));
Ejemplo n.º 5
0
 /// <summary>
 /// Handles the serialization using the specified serializer
 /// </summary>
 /// <param name="s">The serializer</param>
 public void Serialize(IBinarySerializer s)
 {
     VersionLength     = s.Serialize <int>(VersionLength, name: nameof(VersionLength));
     Version           = s.SerializeString(Version, VersionLength + 1, name: nameof(Version));
     SlotCount         = s.Serialize <int>(SlotCount, name: nameof(SlotCount));
     Slots             = s.SerializeObjectArray <Rayman2PCConfigSlotData>(Slots, SlotCount, name: nameof(Slots));
     UnkDword1         = s.Serialize <int>(UnkDword1, name: nameof(UnkDword1));
     UnkDword2         = s.Serialize <int>(UnkDword2, name: nameof(UnkDword2));
     Lumonosity        = s.Serialize <int>(Lumonosity, name: nameof(Lumonosity));
     SoundEffectVolume = s.Serialize <int>(SoundEffectVolume, name: nameof(SoundEffectVolume));
     MusicVolume       = s.Serialize <int>(MusicVolume, name: nameof(MusicVolume));
     UnkDword6         = s.Serialize <int>(UnkDword6, name: nameof(UnkDword6));
     Unk2 = s.SerializeArray <byte>(Unk2, 7, name: nameof(Unk2));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Read the unknown value
            Unknown = s.Serialize <ushort>(Unknown, name: nameof(Unknown));

            // Create the level collection
            Levels = s.SerializeObjectArray <FiestaRunPCSaveDataLevel>(Levels, 72, name: nameof(Levels));

            // Read unknown bytes
            Unknown1 = s.SerializeArray <byte>(Unknown1, 128, name: nameof(Unknown1));

            // Read Lums
            Lums = s.Serialize <uint>(Lums, name: nameof(Lums));

            // Read remaining bytes
            Unknown2 = s.SerializeArray <byte>(Unknown2, (int)(s.Stream.Length - s.Stream.Position), name: nameof(Unknown2));
        }
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            SaveName       = s.SerializeString(SaveName, 4, name: nameof(SaveName));
            ContinuesCount = s.Serialize <byte>(ContinuesCount, name: nameof(ContinuesCount));
            Wi_Save_Zone   = s.SerializeObjectArray <Rayman1PCSaveDataLevel>(Wi_Save_Zone, 24, name: nameof(Wi_Save_Zone));
            RayEvts        = s.Serialize <RayEvtsFlags>(RayEvts, name: nameof(RayEvts));
            Poing          = s.SerializeArray <byte>(Poing, 20, name: nameof(Poing));
            StatusBar      = s.SerializeObject <Rayman1PCSaveDataStatusBar>(StatusBar, name: nameof(StatusBar));
            CurrentHealth  = s.Serialize <byte>(CurrentHealth, name: nameof(CurrentHealth));

            SaveZone ??= new byte[81][];

            for (int i = 0; i < SaveZone.Length; i++)
            {
                SaveZone[i] = s.SerializeArray <byte>(SaveZone[i], 32, name: $"{nameof(SaveZone)}[{i}]");
            }

            BonusPerfect = s.SerializeArray <byte>(BonusPerfect, 24, name: nameof(BonusPerfect));
            WorldIndex   = s.Serialize <ushort>(WorldIndex, name: nameof(WorldIndex));
            FinBossLevel = s.Serialize <Rayman1FinBossLevelFlags>(FinBossLevel, name: nameof(FinBossLevel));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Serialize the directory and file array sizes
            Directories = s.SerializeArraySize <string, int>(Directories, name: nameof(Directories));
            Files       = s.SerializeArraySize <OpenSpaceCntFileEntry, int>(Files, name: nameof(Files));

            // Serialize header info
            IsXORUsed      = s.Serialize <bool>(IsXORUsed, name: nameof(IsXORUsed));
            IsChecksumUsed = s.Serialize <bool>(IsChecksumUsed, name: nameof(IsChecksumUsed));
            XORKey         = s.Serialize <byte>(XORKey, name: nameof(XORKey));

            // Serialize the directory paths
            for (int i = 0; i < Directories.Length; i++)
            {
                Directories[i] = s.SerializeOpenSpaceEncryptedString(Directories[i], IsXORUsed ? XORKey : (byte)0, name: $"{nameof(Directories)}[{i}]");
            }

            // Serialize the directory checksum
            DirChecksum = s.Serialize <byte>(DirChecksum, name: nameof(DirChecksum));

            // Serialize the file info
            Files = s.SerializeObjectArray <OpenSpaceCntFileEntry>(Files, Files.Length, (s, o) => o.XORKey = IsXORUsed ? XORKey : (byte)0, name: nameof(Files));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Serialize and verify the magic header
            MagicHeader = s.Serialize <uint>(MagicHeader, name: nameof(MagicHeader));

            if (MagicHeader != 0x50EC12BA)
            {
                throw new Exception("The IPK header is not valid");
            }

            // Serialize version
            Version = s.Serialize <uint>(Version, name: nameof(Version));

            // Serialize first unknown value
            Unknown1 = s.Serialize <uint>(Unknown1, name: nameof(Unknown1));

            // Serialize second unknown value if version is above or equal to 8
            if (Version >= 8)
            {
                Unknown2 = s.Serialize <uint>(Unknown2, name: nameof(Unknown2));
            }

            // Serialize offset and file count
            BaseOffset = s.Serialize <uint>(BaseOffset, name: nameof(BaseOffset));
            FilesCount = s.Serialize <uint>(FilesCount, name: nameof(FilesCount));

            // Serialize unknown values
            Unknown3 = s.SerializeBool <uint>(Unknown3, name: nameof(Unknown3));
            Unknown4 = s.SerializeBool <uint>(Unknown4, name: nameof(Unknown4));
            Unknown5 = s.SerializeBool <uint>(Unknown5, name: nameof(Unknown5));
            Unknown6 = s.Serialize <uint>(Unknown6, name: nameof(Unknown6));

            if (s.GetSettings <UbiArtSettings>().Game == UbiArtGame.ValiantHearts)
            {
                Unknown9 = s.Serialize <uint>(Unknown9, name: nameof(Unknown9));
            }

            Unknown7      = s.Serialize <uint>(Unknown7, name: nameof(Unknown7));
            EngineVersion = s.Serialize <uint>(EngineVersion, name: nameof(EngineVersion));

            if (SupportsCompressedBlock)
            {
                BlockSize           = s.Serialize <uint>(BlockSize, name: nameof(BlockSize));
                BlockCompressedSize = s.Serialize <uint>(BlockCompressedSize, name: nameof(BlockCompressedSize));
            }

            // Serialize the file array size
            Files = s.SerializeArraySize <UbiArtIPKFileEntry, uint>(Files, name: nameof(Files));

            // NOTE: So far this only appears to be the case for the bundle_pc32.ipk file used in Child of Light
            // TODO: Add logging when migrated to BinarySerializer
            //if (Files.Length != FilesCount)
            //    Logger.Warn("The initial file count {0} does not match the file array size {1}", FilesCount, Files.Length);

            // Serialize the file entries
            Files = s.SerializeObjectArray <UbiArtIPKFileEntry>(Files, Files.Length, (s, o) => o.IPKVersion = Version, name: nameof(Files));

            // TODO: Add logging when migrated to BinarySerializer
            //if (!IsSerializingHeaderSize && s.Stream.Position != BaseOffset)
            //    Logger.Warn("Offset value {0} doesn't match file entry end offset {1}", BaseOffset, s.Stream.Position);
        }