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); } }
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 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); } Personal = PersonalTable.RS; HeldItems = Legal.HeldItems_RS; if (!Exportable) { ClearBoxes(); } }