Skip to content

Commit

Permalink
Added key_items and implemented item filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
clayamore committed Feb 28, 2024
1 parent d8cb929 commit 0863271
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/.vscode
100 changes: 14 additions & 86 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ env_logger = "0.11.2"
md5 = "0.7.0"
once_cell = "1.19.0"
rfd = "0.13.0"
sled = "0.34.7"
strsim = "0.11.0"
32 changes: 16 additions & 16 deletions src/save/save_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,21 +707,21 @@ impl Write for EquipInventoryItem {

#[derive(Clone)]
pub struct EquipInventoryData {
pub inventory_distinct_item_count: i32,
pub inventory_items: Vec<EquipInventoryItem>,
pub inventory_distinct_item_count2: i32,
pub inventory_items2: Vec<EquipInventoryItem>,
pub common_inventory_items_distinct_count: i32,
pub common_items: Vec<EquipInventoryItem>,
pub key_inventory_items_distinct_count: i32,
pub key_items: Vec<EquipInventoryItem>,
_0x4: i32,
_0x4_1: i32,
}

impl Default for EquipInventoryData {
fn default() -> Self {
Self {
inventory_distinct_item_count: Default::default(),
inventory_items: vec![],
inventory_distinct_item_count2: Default::default(),
inventory_items2: vec![],
common_inventory_items_distinct_count: Default::default(),
common_items: vec![],
key_inventory_items_distinct_count: Default::default(),
key_items: vec![],
_0x4: -1,
_0x4_1: -1,
}
Expand All @@ -732,16 +732,16 @@ impl EquipInventoryData {
fn read(br: &mut BinaryReader, length1: usize, length2: usize) -> Result<EquipInventoryData, io::Error> {
let mut equip_inventory_data = EquipInventoryData::default();

equip_inventory_data.inventory_distinct_item_count = br.read_i32()?;
equip_inventory_data.common_inventory_items_distinct_count = br.read_i32()?;

for _i in 0..length1 {
equip_inventory_data.inventory_items.push(EquipInventoryItem::read(br)?);
equip_inventory_data.common_items.push(EquipInventoryItem::read(br)?);
}

equip_inventory_data.inventory_distinct_item_count2 = br.read_i32()?;
equip_inventory_data.key_inventory_items_distinct_count = br.read_i32()?;

for _i in 0..length2 {
equip_inventory_data.inventory_items2.push(EquipInventoryItem::read(br)?);
equip_inventory_data.key_items.push(EquipInventoryItem::read(br)?);
}

equip_inventory_data._0x4 = br.read_i32()?;
Expand All @@ -753,16 +753,16 @@ impl EquipInventoryData {
fn write(&self, length1: usize, length2: usize) -> Result<Vec<u8>, io::Error>{
let mut bytes: Vec<u8> = Vec::new();

bytes.extend(self.inventory_distinct_item_count.to_le_bytes());
bytes.extend(self.common_inventory_items_distinct_count.to_le_bytes());

for i in 0..length1 {
bytes.extend(self.inventory_items[i].write()?);
bytes.extend(self.common_items[i].write()?);
}

bytes.extend(self.inventory_distinct_item_count2.to_le_bytes());
bytes.extend(self.key_inventory_items_distinct_count.to_le_bytes());

for i in 0..length2 {
bytes.extend(self.inventory_items2[i].write()?);
bytes.extend(self.key_items[i].write()?);
}

bytes.extend(self._0x4.to_le_bytes());
Expand Down
Loading

0 comments on commit 0863271

Please sign in to comment.