示例#1
0
文件: SaveUtil.cs 项目: funagi/PKHeX
        /// <summary>Determines the type of 4th gen Battle Revolution</summary>
        /// <param name="data">Save data of which to determine the type</param>
        /// <returns>Version Identifier or Invalid if type cannot be determined.</returns>
        public static GameVersion getIsG4BRSAV(byte[] data)
        {
            if (data.Length != SIZE_G4BR)
            {
                return(GameVersion.Invalid);
            }

            byte[] sav = SAV4BR.DecryptPBRSaveData(data);

            bool valid = SAV4BR.VerifyChecksum(sav, 0, 0x1C0000, 0x1BFF80);

            valid &= SAV4BR.VerifyChecksum(sav, 0, 0x100, 8);
            valid &= SAV4BR.VerifyChecksum(sav, 0x1C0000, 0x1C0000, 0x1BFF80 + 0x1C0000);
            valid &= SAV4BR.VerifyChecksum(sav, 0x1C0000, 0x100, 0x1C0008);

            return(valid ? GameVersion.BATREV : GameVersion.Invalid);
        }
示例#2
0
文件: SaveUtil.cs 项目: funagi/PKHeX
        /// <summary>Creates an instance of a SaveFile using the given save data.</summary>
        /// <param name="data">Save data from which to create a SaveFile.</param>
        /// <returns>An appropriate type of save file for the given data, or null if the save data is invalid.</returns>
        public static SaveFile getVariantSAV(byte[] data)
        {
            // Pre-check for header/footer signatures
            SaveFile sav;

            byte[] header = new byte[0], footer = new byte[0];
            CheckHeaderFooter(ref data, ref header, ref footer);

            switch (getSAVGeneration(data))
            {
            // Main Games
            case GameVersion.Gen1:      sav = new SAV1(data); break;

            case GameVersion.Gen2:      sav = new SAV2(data); break;

            case GameVersion.Gen3:      sav = new SAV3(data); break;

            case GameVersion.Gen4:      sav = new SAV4(data); break;

            case GameVersion.Gen5:      sav = new SAV5(data); break;

            case GameVersion.Gen6:      sav = new SAV6(data); break;

            case GameVersion.Gen7:      sav = new SAV7(data); break;

            // Side Games
            case GameVersion.COLO:      sav = new SAV3Colosseum(data); break;

            case GameVersion.XD:        sav = new SAV3XD(data); break;

            case GameVersion.RSBOX:     sav = new SAV3RSBox(data); break;

            case GameVersion.BATREV:    sav = new SAV4BR(data); break;

            // No pattern matched
            default: return(null);
            }
            sav.Header = header;
            sav.Footer = footer;
            return(sav);
        }
        /// <summary>Creates an instance of a SaveFile using the given save data.</summary>
        /// <param name="data">Save data from which to create a SaveFile.</param>
        /// <returns>An appropriate type of save file for the given data, or null if the save data is invalid.</returns>
        public static SaveFile getVariantSAV(byte[] data)
        {
            // Pre-check for header/footer signatures
            SaveFile sav;
            byte[] header = new byte[0], footer = new byte[0];
            CheckHeaderFooter(ref data, ref header, ref footer);

            switch (getSAVGeneration(data))
            {
                // Main Games
                case GameVersion.Gen1:      sav = new SAV1(data); break;
                case GameVersion.Gen2:      sav = new SAV2(data); break;
                case GameVersion.Gen3:      sav = new SAV3(data); break;
                case GameVersion.Gen4:      sav = new SAV4(data); break;
                case GameVersion.Gen5:      sav = new SAV5(data); break;
                case GameVersion.Gen6:      sav = new SAV6(data); break;
                case GameVersion.Gen7:      sav = new SAV7(data); break;

                // Side Games
                case GameVersion.COLO:      sav = new SAV3Colosseum(data); break;
                case GameVersion.XD:        sav = new SAV3XD(data); break;
                case GameVersion.RSBOX:     sav = new SAV3RSBox(data); break;
                case GameVersion.BATREV:    sav = new SAV4BR(data); break;

                // No pattern matched
                default: return null;
            }
            sav.Header = header;
            sav.Footer = footer;
            return sav;
        }