mirror of
https://github.com/redstrate/Kawari.git
synced 2025-05-01 18:57:45 +00:00
Add ContainerType enum
This commit is contained in:
parent
264fac4b4e
commit
48b1b9cdc2
3 changed files with 21 additions and 5 deletions
|
@ -1,12 +1,26 @@
|
|||
use binrw::binrw;
|
||||
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[brw(repr = u16)]
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub enum ContainerType {
|
||||
#[default]
|
||||
Inventory0 = 0,
|
||||
Inventory1 = 1,
|
||||
Inventory2 = 2,
|
||||
Inventory3 = 3,
|
||||
Equipped = 1000,
|
||||
}
|
||||
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ContainerInfo {
|
||||
pub sequence: u32,
|
||||
pub num_items: u32,
|
||||
pub container_id: u32,
|
||||
#[brw(pad_after = 2)] // not used
|
||||
pub container: ContainerType,
|
||||
pub start_or_finish: u32,
|
||||
}
|
||||
|
||||
|
@ -29,7 +43,7 @@ mod tests {
|
|||
let container_info = ContainerInfo::read_le(&mut buffer).unwrap();
|
||||
assert_eq!(container_info.sequence, 1);
|
||||
assert_eq!(container_info.num_items, 0);
|
||||
assert_eq!(container_info.container_id, 1);
|
||||
assert_eq!(container_info.container, ContainerType::Inventory1);
|
||||
assert_eq!(container_info.start_or_finish, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
use binrw::binrw;
|
||||
|
||||
use super::ContainerType;
|
||||
|
||||
#[binrw]
|
||||
#[brw(little)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ItemInfo {
|
||||
pub sequence: u32,
|
||||
pub unk1: u32,
|
||||
pub container_id: u16,
|
||||
pub container: ContainerType,
|
||||
pub slot: u16,
|
||||
pub quantity: u32,
|
||||
pub catalog_id: u32,
|
||||
|
@ -42,7 +44,7 @@ mod tests {
|
|||
let item_info = ItemInfo::read_le(&mut buffer).unwrap();
|
||||
assert_eq!(item_info.sequence, 4);
|
||||
assert_eq!(item_info.unk1, 0);
|
||||
assert_eq!(item_info.container_id, 1000);
|
||||
assert_eq!(item_info.container, ContainerType::Equipped);
|
||||
assert_eq!(item_info.slot, 11);
|
||||
assert_eq!(item_info.quantity, 1);
|
||||
assert_eq!(item_info.catalog_id, 4426);
|
||||
|
|
|
@ -48,7 +48,7 @@ mod action_request;
|
|||
pub use action_request::ActionRequest;
|
||||
|
||||
mod container_info;
|
||||
pub use container_info::ContainerInfo;
|
||||
pub use container_info::{ContainerInfo, ContainerType};
|
||||
|
||||
mod item_info;
|
||||
pub use item_info::ItemInfo;
|
||||
|
|
Loading…
Add table
Reference in a new issue