/// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public virtual void Serialize(IBinarySerializer s)
        {
            // Get the settings
            var settings = s.GetSettings <Ray1Settings>();

            if (settings.Game != Ray1Game.Rayman1 && settings.Platform == Platform.PC)
            {
                PrimaryKitHeader   = s.SerializeString(PrimaryKitHeader, 5, name: nameof(PrimaryKitHeader));
                SecondaryKitHeader = s.SerializeString(SecondaryKitHeader, 5, name: nameof(SecondaryKitHeader));
                Short_0A           = s.Serialize <short>(Short_0A, name: nameof(Short_0A));
            }
        }
예제 #2
0
 public void Serialize(IBinarySerializer s)
 {
     if (s.GetSettings <UbiArtSettings>().Game == UbiArtGame.RaymanOrigins)
     {
         Id = s.SerializeLengthPrefixedString(Id, name: nameof(Id));
     }
     else
     {
         Levels   = s.SerializeUbiArtObjectArray <Level>(Levels, name: nameof(Levels));
         Id       = s.SerializeLengthPrefixedString(Id, name: nameof(Id));
         Absolute = s.SerializeBool <uint>(Absolute, name: nameof(Absolute));
     }
 }
예제 #3
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Just Dance reads the values in reverse
            if (s.GetSettings <UbiArtSettings>().Game == UbiArtGame.JustDance2017)
            {
                // Read the path
                FileName      = s.SerializeLengthPrefixedString(FileName, name: nameof(FileName));
                DirectoryPath = s.SerializeLengthPrefixedString(DirectoryPath, name: nameof(DirectoryPath));
            }
            else
            {
                // Read the path
                DirectoryPath = s.SerializeLengthPrefixedString(DirectoryPath, name: nameof(DirectoryPath));
                FileName      = s.SerializeLengthPrefixedString(FileName, name: nameof(FileName));
            }

            StringID = s.SerializeObject <UbiArtStringID>(StringID, name: nameof(StringID));

            if (s.GetSettings <UbiArtSettings>().Game != UbiArtGame.RaymanOrigins)
            {
                Flags = s.Serialize <uint>(Flags, name: nameof(Flags));
            }
        }
예제 #4
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Get the settings
            var settings = s.GetSettings <Ray1Settings>();

            if (settings.Game == Ray1Game.Rayman1)
            {
                FileOffset = s.Serialize <uint>(FileOffset, name: nameof(FileOffset));
                FileSize   = s.Serialize <uint>(FileSize, name: nameof(FileSize));
                XORKey     = s.Serialize <byte>(XORKey, name: nameof(XORKey));
                Checksum   = s.Serialize <byte>(Checksum, name: nameof(Checksum));

                s.SerializeArray <byte>(new byte[2], 2, name: "Padding");
            }
            else
            {
                XORKey     = s.Serialize <byte>(XORKey, name: nameof(XORKey));
                Checksum   = s.Serialize <byte>(Checksum, name: nameof(Checksum));
                FileOffset = s.Serialize <uint>(FileOffset, name: nameof(FileOffset));
                FileSize   = s.Serialize <uint>(FileSize, name: nameof(FileSize));

                s.DoXOR(XORKey, () => FileName = s.SerializeString(FileName, 9, name: nameof(FileName)));
            }
        }
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Get the settings
            var settings = s.GetSettings <Ray1Settings>();

            if (settings.Game == Ray1Game.Rayman1)
            {
                Language = s.Serialize <R1Languages>(Language, name: nameof(Language));
            }

            Port           = s.Serialize <uint>(Port, name: nameof(Port));
            Irq            = s.Serialize <uint>(Irq, name: nameof(Irq));
            Dma            = s.Serialize <uint>(Dma, name: nameof(Dma));
            Param          = s.Serialize <uint>(Param, name: nameof(Param));
            DeviceID       = s.Serialize <uint>(DeviceID, name: nameof(DeviceID));
            NumCard        = s.Serialize <byte>(NumCard, name: nameof(NumCard));
            KeyJump        = s.Serialize <ushort>(KeyJump, name: nameof(KeyJump));
            KeyWeapon      = s.Serialize <ushort>(KeyWeapon, name: nameof(KeyWeapon));
            Options_jeu_10 = s.Serialize <ushort>(Options_jeu_10, name: nameof(Options_jeu_10));
            KeyAction      = s.Serialize <ushort>(KeyAction, name: nameof(KeyAction));

            MusicCdActive = s.Serialize <ushort>(MusicCdActive, name: nameof(MusicCdActive));
            VolumeSound   = s.Serialize <ushort>(VolumeSound, name: nameof(VolumeSound));

            IsStero = s.Serialize <ushort>(IsStero, name: nameof(IsStero));

            if (settings.Game != Ray1Game.Rayman1)
            {
                EDU_VoiceSound = s.Serialize <ushort>(EDU_VoiceSound, name: nameof(EDU_VoiceSound));
            }

            Mode_Pad = s.Serialize <bool>(Mode_Pad, name: nameof(Mode_Pad));
            Port_Pad = s.Serialize <byte>(Port_Pad, name: nameof(Port_Pad));

            XPadMax    = s.Serialize <short>(XPadMax, name: nameof(XPadMax));
            XPadMin    = s.Serialize <short>(XPadMin, name: nameof(XPadMin));
            YPadMax    = s.Serialize <short>(YPadMax, name: nameof(YPadMax));
            YPadMin    = s.Serialize <short>(YPadMin, name: nameof(YPadMin));
            XPadCentre = s.Serialize <short>(XPadCentre, name: nameof(XPadCentre));
            YPadCentre = s.Serialize <short>(YPadCentre, name: nameof(YPadCentre));

            NotBut  = s.SerializeArray <byte>(NotBut, 4, name: nameof(NotBut));
            Tab_Key = s.SerializeArray <byte>(Tab_Key, 7, name: nameof(Tab_Key));

            GameModeVideo      = s.Serialize <byte>(GameModeVideo, name: nameof(GameModeVideo));
            P486               = s.Serialize <byte>(P486, name: nameof(P486));
            SizeScreen         = s.Serialize <byte>(SizeScreen, name: nameof(SizeScreen));
            Frequence          = s.Serialize <Rayman1Freq>(Frequence, name: nameof(Frequence));
            FixOn              = s.Serialize <bool>(FixOn, name: nameof(FixOn));
            BackgroundOptionOn = s.Serialize <bool>(BackgroundOptionOn, name: nameof(BackgroundOptionOn));
            ScrollDiffOn       = s.Serialize <bool>(ScrollDiffOn, name: nameof(ScrollDiffOn));

            RefRam2VramNormalFix = s.SerializeArray <ushort>(RefRam2VramNormalFix, 8, name: nameof(RefRam2VramNormalFix));
            RefRam2VramNormal    = s.SerializeArray <ushort>(RefRam2VramNormal, 8, name: nameof(RefRam2VramNormal));
            RefTransFondNormal   = s.SerializeArray <ushort>(RefTransFondNormal, 8, name: nameof(RefTransFondNormal));

            RefSpriteNormal = s.SerializeArray <ushort>(RefSpriteNormal, 2, name: nameof(RefSpriteNormal));
            RefRam2VramX    = s.SerializeArray <ushort>(RefRam2VramX, 2, name: nameof(RefRam2VramX));
            RefVram2VramX   = s.SerializeArray <ushort>(RefVram2VramX, 2, name: nameof(RefVram2VramX));
            RefSpriteX      = s.SerializeArray <ushort>(RefSpriteX, 2, name: nameof(RefSpriteX));
        }
예제 #6
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);
        }