1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-12 08:47:45 +00:00
kawari/src/ipc/zone/inventory_modify.rs

60 lines
1.8 KiB
Rust
Raw Normal View History

use binrw::binrw;
use crate::inventory::ContainerType;
#[binrw]
#[derive(Debug, Clone, Default)]
pub struct InventoryModify {
pub context_id: u32,
pub operation_type: u8,
#[brw(pad_before = 3)]
pub src_actor_id: u32,
#[brw(pad_size_to = 4)]
pub src_storage_id: ContainerType,
pub src_container_index: u16,
#[brw(pad_before = 2)]
pub src_stack: u32,
pub src_catalog_id: u32,
pub dst_actor_id: u32,
#[brw(pad_size_to = 4)]
pub dst_storage_id: ContainerType,
pub dst_container_index: u16,
#[brw(pad_before = 2)]
pub dst_stack: u32,
pub dst_catalog_id: u32,
}
#[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();
assert_eq!(modify_inventory.context_id, 0x10000000);
2025-05-01 23:34:06 -04:00
assert_eq!(modify_inventory.operation_type, 60);
assert_eq!(modify_inventory.src_actor_id, 0);
assert_eq!(modify_inventory.src_storage_id, ContainerType::Equipped);
assert_eq!(modify_inventory.src_container_index, 3);
assert_eq!(modify_inventory.src_stack, 1);
assert_eq!(modify_inventory.src_catalog_id, 0);
assert_eq!(modify_inventory.dst_actor_id, 0);
assert_eq!(modify_inventory.dst_storage_id, ContainerType::ArmoryBody);
assert_eq!(modify_inventory.dst_container_index, 0);
assert_eq!(modify_inventory.dst_stack, 0);
2025-03-31 21:58:51 -04:00
assert_eq!(modify_inventory.dst_catalog_id, 0);
}
}