2025-03-31 20:05:37 -04:00
|
|
|
use binrw::binrw;
|
|
|
|
|
2025-05-02 16:15:54 -04:00
|
|
|
use crate::inventory::ContainerType;
|
2025-03-31 23:23:29 -04:00
|
|
|
|
2025-03-31 20:05:37 -04:00
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
|
|
pub struct InventoryModify {
|
2025-03-31 21:49:12 -04:00
|
|
|
pub context_id: u32,
|
2025-05-01 23:20:56 -04:00
|
|
|
pub operation_type: u8,
|
2025-03-31 23:23:29 -04:00
|
|
|
|
2025-05-01 23:20:56 -04:00
|
|
|
#[brw(pad_before = 3)]
|
2025-03-31 21:49:12 -04:00
|
|
|
pub src_actor_id: u32,
|
2025-03-31 23:23:29 -04:00
|
|
|
#[brw(pad_size_to = 4)]
|
|
|
|
pub src_storage_id: ContainerType,
|
|
|
|
pub src_container_index: u16,
|
|
|
|
#[brw(pad_before = 2)]
|
2025-03-31 21:49:12 -04:00
|
|
|
pub src_stack: u32,
|
|
|
|
pub src_catalog_id: u32,
|
2025-03-31 23:23:29 -04:00
|
|
|
|
2025-03-31 21:49:12 -04:00
|
|
|
pub dst_actor_id: u32,
|
2025-03-31 23:23:29 -04:00
|
|
|
#[brw(pad_size_to = 4)]
|
|
|
|
pub dst_storage_id: ContainerType,
|
|
|
|
pub dst_container_index: u16,
|
|
|
|
#[brw(pad_before = 2)]
|
2025-03-31 21:49:12 -04:00
|
|
|
pub dst_stack: u32,
|
|
|
|
pub dst_catalog_id: u32,
|
2025-03-31 20:05:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use std::{fs::read, io::Cursor, path::PathBuf};
|
|
|
|
|
|
|
|
use binrw::BinRead;
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn read_inventory_modify() {
|
|
|
|
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
|
|
d.push("resources/tests/inventory_modify.bin");
|
|
|
|
|
|
|
|
let buffer = read(d).unwrap();
|
|
|
|
let mut buffer = Cursor::new(&buffer);
|
|
|
|
|
|
|
|
let modify_inventory = InventoryModify::read_le(&mut buffer).unwrap();
|
2025-03-31 23:23:29 -04:00
|
|
|
assert_eq!(modify_inventory.context_id, 0x10000000);
|
2025-05-01 23:34:06 -04:00
|
|
|
assert_eq!(modify_inventory.operation_type, 60);
|
2025-03-31 20:05:37 -04:00
|
|
|
assert_eq!(modify_inventory.src_actor_id, 0);
|
2025-03-31 23:23:29 -04:00
|
|
|
assert_eq!(modify_inventory.src_storage_id, ContainerType::Equipped);
|
|
|
|
assert_eq!(modify_inventory.src_container_index, 3);
|
|
|
|
assert_eq!(modify_inventory.src_stack, 1);
|
2025-03-31 20:05:37 -04:00
|
|
|
assert_eq!(modify_inventory.src_catalog_id, 0);
|
2025-03-31 23:23:29 -04:00
|
|
|
assert_eq!(modify_inventory.dst_actor_id, 0);
|
2025-05-02 16:15:54 -04:00
|
|
|
assert_eq!(modify_inventory.dst_storage_id, ContainerType::ArmoryBody);
|
2025-03-31 23:23:29 -04:00
|
|
|
assert_eq!(modify_inventory.dst_container_index, 0);
|
2025-03-31 20:05:37 -04:00
|
|
|
assert_eq!(modify_inventory.dst_stack, 0);
|
2025-03-31 21:58:51 -04:00
|
|
|
assert_eq!(modify_inventory.dst_catalog_id, 0);
|
2025-03-31 20:05:37 -04:00
|
|
|
}
|
|
|
|
}
|