1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-17 10:47:44 +00:00
kawari/src/ipc/zone/container_info.rs
Joshua Goins 8d384c4bd0 Overhaul how we send inventory packets again
I wanted to add armory chest support but the current state of the
inventory was a little frustrating. Adding new containers was too
difficult, so I made the system *even more* generic and easier to use. I
have also split it up into it's own module with a nicer file layout.

Oh yeah, and armory chest works too now.
2025-05-02 16:15:54 -04:00

38 lines
960 B
Rust

use binrw::binrw;
use crate::inventory::ContainerType;
#[binrw]
#[brw(little)]
#[derive(Debug, Clone, Default)]
pub struct ContainerInfo {
pub sequence: u32,
pub num_items: u32,
#[brw(pad_size_to = 4)]
pub container: ContainerType,
pub start_or_finish: u32,
}
#[cfg(test)]
mod tests {
use std::{fs::read, io::Cursor, path::PathBuf};
use binrw::BinRead;
use super::*;
#[test]
fn read_containerinfo() {
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
d.push("resources/tests/container_info.bin");
let buffer = read(d).unwrap();
let mut buffer = Cursor::new(&buffer);
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, ContainerType::Inventory1);
assert_eq!(container_info.start_or_finish, 0);
}
}