Exemplo n.º 1
0
        private void InitializeData()
        {
            Blocks = new BlockInfoRSBOX[2 * BLOCK_COUNT];
            for (int i = 0; i < Blocks.Length; i++)
            {
                int offset = BLOCK_SIZE + (i * BLOCK_SIZE);
                Blocks[i] = new BlockInfoRSBOX(Data, offset);
            }

            // Detect active save
            int[] SaveCounts = Blocks.Select(block => (int)block.SaveCount).ToArray();
            SaveCount = SaveCounts.Max();
            int ActiveSAV = Array.IndexOf(SaveCounts, SaveCount) / BLOCK_COUNT;

            Blocks = Blocks.Skip(ActiveSAV * BLOCK_COUNT).Take(BLOCK_COUNT).OrderBy(b => b.ID).ToArray();

            // Set up PC data buffer beyond end of save file.
            Box = Data.Length;
            Array.Resize(ref Data, Data.Length + SIZE_RESERVED); // More than enough empty space.

            // Copy block to the allocated location
            const int copySize = BLOCK_SIZE - 0x10;

            foreach (var b in Blocks)
            {
                Array.Copy(Data, b.Offset + 0xC, Data, (int)(Box + (b.ID * copySize)), copySize);
            }
        }
Exemplo n.º 2
0
        private static BlockInfoRSBOX[] ReadBlocks(byte[] data)
        {
            var blocks = new BlockInfoRSBOX[2 * BLOCK_COUNT];

            for (int i = 0; i < blocks.Length; i++)
            {
                int offset = BLOCK_SIZE + (i * BLOCK_SIZE);
                blocks[i] = new BlockInfoRSBOX(data, offset);
            }

            return(blocks);
        }
Exemplo n.º 3
0
        public SAV3RSBox(byte[] data = null)
        {
            Data       = data ?? new byte[SaveUtil.SIZE_G3BOX];
            BAK        = (byte[])Data.Clone();
            Exportable = !IsRangeEmpty(0, Data.Length);

            if (SaveUtil.GetIsG3BOXSAV(Data) != GameVersion.RSBOX)
            {
                return;
            }

            Blocks = new BlockInfo[2 * BLOCK_COUNT];
            for (int i = 0; i < Blocks.Length; i++)
            {
                int offset = BLOCK_SIZE + (i * BLOCK_SIZE);
                Blocks[i] = new BlockInfoRSBOX(Data, offset);
            }

            // Detect active save
            int[] SaveCounts = Blocks.OfType <BlockInfoRSBOX>().Select(block => (int)block.SaveCount).ToArray();
            SaveCount = SaveCounts.Max();
            int ActiveSAV = Array.IndexOf(SaveCounts, SaveCount) / BLOCK_COUNT;

            Blocks = Blocks.Skip(ActiveSAV * BLOCK_COUNT).Take(BLOCK_COUNT).OrderBy(b => b.ID).ToArray();

            // Set up PC data buffer beyond end of save file.
            Box = Data.Length;
            Array.Resize(ref Data, Data.Length + SIZE_RESERVED); // More than enough empty space.

            // Copy block to the allocated location
            const int copySize = BLOCK_SIZE - 0x10;

            foreach (var b in Blocks)
            {
                Array.Copy(Data, b.Offset + 0xC, Data, (int)(Box + (b.ID * copySize)), copySize);
            }

            Personal  = PersonalTable.RS;
            HeldItems = Legal.HeldItems_RS;

            if (!Exportable)
            {
                ClearBoxes();
            }
        }