Exemplo n.º 1
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            KeyLength = s.Serialize <byte>(KeyLength, name: nameof(KeyLength));

            if (KeyLength == 0x00)
            {
                return;
            }

            Key         = s.SerializeString(Key, KeyLength, name: nameof(Key));
            ValueType   = s.Serialize <byte>(ValueType, name: nameof(ValueType));
            ValuesCount = s.Serialize <byte>(ValuesCount, name: nameof(ValuesCount));

            if (GetValueType == EntryValueTypes.String)
            {
                if (StringValues == null || s.IsReading)
                {
                    StringValues = new string[ValuesCount];
                }
            }
            else
            {
                if (Values == null || s.IsReading)
                {
                    Values = new int[ValuesCount];
                }
            }

            for (int i = 0; i < ValuesCount; i++)
            {
                switch (GetValueType)
                {
                case EntryValueTypes.Byte:
                    Values[i] = s.Serialize <byte>((byte)Values[i], name: $"{nameof(Values)}[{i}]");
                    break;

                case EntryValueTypes.Short:
                    Values[i] = s.Serialize <short>((short)Values[i], name: $"{nameof(Values)}[{i}]");
                    break;

                case EntryValueTypes.Int:
                    Values[i] = s.Serialize <int>(Values[i], name: $"{nameof(Values)}[{i}]");
                    break;

                case EntryValueTypes.String:
                    var length = s.Serialize <byte>((byte)(StringValues[i]?.Length ?? 0), name: $"ValueLength");
                    StringValues[i] = s.SerializeString(StringValues[i], length, name: $"{nameof(StringValues)}[{i}]");
                    break;

                // These are never used in save files, so ignore for now
                default:
                case EntryValueTypes.Float:
                case EntryValueTypes.Vector:
                    // An array of bytes of size 0x0C
                    throw new NotImplementedException($"The specified save value type {GetValueType} is currently not supported");
                }
            }
        }
        /// <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));
            }
        }
Exemplo n.º 3
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}]"));
Exemplo n.º 4
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Serialize header
            Header = s.SerializeString(Header, 12, name: nameof(Header));
            Time1  = s.Serialize <int>(Time1, name: nameof(Time1));
            Time2  = s.Serialize <int>(Time2, name: nameof(Time2));

            // Serialize unknown data
            Dword_14 = s.Serialize <uint>(Dword_14, name: nameof(Dword_14));
            Dword_18 = s.Serialize <uint>(Dword_18, name: nameof(Dword_18));
            Dword_1C = s.Serialize <uint>(Dword_1C, name: nameof(Dword_1C));
            Dword_20 = s.Serialize <uint>(Dword_20, name: nameof(Dword_20));
            Dword_24 = s.Serialize <uint>(Dword_24, name: nameof(Dword_24));
            Dword_28 = s.Serialize <uint>(Dword_28, name: nameof(Dword_28));
            Dword_2C = s.Serialize <uint>(Dword_2C, name: nameof(Dword_2C));
            Dword_30 = s.Serialize <uint>(Dword_30, name: nameof(Dword_30));
            Dword_34 = s.Serialize <uint>(Dword_34, name: nameof(Dword_34));

            // Serialize data entries
            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}]"));
        /// <summary>
        /// Serializes a string with the length prefixed as a 32-bit integer
        /// </summary>
        /// <param name="s">The serializer</param>
        /// <param name="value">The string value</param>
        /// <param name="name">The object value name, for logging</param>
        /// <returns>The string value</returns>
        public static string SerializeLengthPrefixedString(this IBinarySerializer s, string value, string name = null)
        {
            // Serialize the length
            var length = s.Serialize <int>(value?.Length ?? 0, name: $"{name}.Length");

            // Serialize the string
            return(s.SerializeString(value, length, name));
        }
        /// <summary>
        /// Serializes an encrypted string for OpenSpace games
        /// </summary>
        /// <param name="s">The serializer</param>
        /// <param name="value">The string value</param>
        /// <param name="xorKey">The xor key to use</param>
        /// <param name="name">The string value name, for logging</param>
        /// <returns>The string value</returns>
        public static string SerializeOpenSpaceEncryptedString(this IBinarySerializer s, string value, byte xorKey, string name = null)
        {
            // Serialize the length
            var length = s.Serialize <int>(value?.Length ?? 0, name: $"{nameof(value)}.Length");

            // Serialize the string value using the xor key
            s.DoXOR(xorKey, () => value = s.SerializeString(value, length, name: $"{nameof(value)}"));

            // Return the value
            return(value);
        }
Exemplo n.º 7
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));
 }
        /// <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));
        }
Exemplo n.º 9
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)
 {
     SlotDisplayName = s.SerializeString(SlotDisplayName, 11, name: nameof(SlotDisplayName));
     SlotIndex       = s.Serialize <int>(SlotIndex, name: nameof(SlotIndex));
 }