private void SaveItems() { // Stored items var compiledItems = new Dictionary <int, int>(); // Key = item ID, value = quantity // - Combine the quantities foreach (var item in StoredItems) { if (!compiledItems.ContainsKey(item.ItemID)) { compiledItems.Add(item.ItemID, 0); } compiledItems[item.ItemID] = Math.Min(item.Quantity + compiledItems[item.ItemID], 1024); } // - Update the save var block = new BitBlock(Offsets.StoredItemCount * 10); for (int i = 0; i < Offsets.StoredItemCount; i++) { if (compiledItems.ContainsKey(i + 1)) { block.SetNextInt(10, compiledItems[i + 1]); } else { block.SetNextInt(10, 0); } } Bits.SetRange(Offsets.StoredItemOffset, Offsets.StoredItemCount * 10, block); // Held items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + i * 33; if (HeldItems.Count > i) { Bits.SetRange(index, 33, HeldItems[i].GetHeldItemBits()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } }
private void SaveItems() { // Stored items var ids = new BitBlock(11 * 1000); var parameters = new BitBlock(11 * 1000); for (int i = 0; i < 1000; i++) { if (StoredItems.Count > i) { ids.SetNextInt(11, StoredItems[i].ID); parameters.SetNextInt(11, StoredItems[i].Parameter); } else { ids.SetNextInt(11, 0); parameters.SetNextInt(11, 0); } } Bits.SetRange(Offsets.StoredItemOffset, 11 * 1000, ids); Bits.SetRange(Offsets.StoredItemOffset + 11 * 1000, 11 * 1000, parameters); // Held items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + i * 33; if (HeldItems.Count > i) { Bits.SetRange(index, 33, HeldItems[i].ToBitBlock()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } // Sp. Episode Held items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + (i + 50) * 33; if (SpEpisodeHeldItems.Count > i) { Bits.SetRange(index, 33, SpEpisodeHeldItems[i].ToBitBlock()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } // Friend RescueHeld items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + (i + 100) * 33; if (HeldItems.Count > i) { Bits.SetRange(index, 33, HeldItems[i].ToBitBlock()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } }