2025-02-19 19:34:13 -05:00
|
|
|
pub mod array_property;
|
|
|
|
pub mod bool_property;
|
2025-02-23 15:25:50 -05:00
|
|
|
mod common;
|
2025-02-19 19:34:13 -05:00
|
|
|
pub mod float_property;
|
|
|
|
pub mod int_property;
|
|
|
|
pub mod map_property;
|
|
|
|
pub mod set_property;
|
|
|
|
pub mod str_property;
|
|
|
|
pub mod struct_property;
|
|
|
|
mod structs;
|
2025-02-23 16:14:44 -05:00
|
|
|
mod guid;
|
2025-02-19 19:34:13 -05:00
|
|
|
|
|
|
|
use binrw::helpers::{until, until_eof};
|
|
|
|
|
|
|
|
use crate::array_property::ArrayProperty;
|
|
|
|
use crate::bool_property::BoolProperty;
|
2025-02-23 16:03:08 -05:00
|
|
|
use crate::common::read_string_with_length;
|
2025-02-19 19:34:13 -05:00
|
|
|
use crate::float_property::FloatProperty;
|
|
|
|
use crate::int_property::IntProperty;
|
|
|
|
use crate::map_property::MapProperty;
|
|
|
|
use crate::set_property::SetProperty;
|
|
|
|
use crate::str_property::StrProperty;
|
|
|
|
use crate::struct_property::StructProperty;
|
|
|
|
use binrw::binrw;
|
|
|
|
|
|
|
|
// Used in ArrayProperty exclusively, but could be used instead of magic above
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[br(import { magic: &str })]
|
2025-02-23 16:03:08 -05:00
|
|
|
pub enum Property {
|
2025-02-19 19:34:13 -05:00
|
|
|
#[br(pre_assert("NameProperty" == magic))]
|
2025-02-23 15:54:17 -05:00
|
|
|
Name(StrProperty),
|
2025-02-19 19:34:13 -05:00
|
|
|
#[br(pre_assert("StructProperty" == magic))]
|
|
|
|
Struct(StructProperty),
|
|
|
|
#[br(pre_assert("FloatProperty" == magic))]
|
|
|
|
Float(FloatProperty),
|
|
|
|
#[br(pre_assert("StrProperty" == magic))]
|
|
|
|
String(StrProperty),
|
|
|
|
#[br(pre_assert("BoolProperty" == magic))]
|
|
|
|
Bool(BoolProperty),
|
|
|
|
#[br(pre_assert("IntProperty" == magic))]
|
|
|
|
Int(IntProperty),
|
2025-02-23 16:00:35 -05:00
|
|
|
#[br(pre_assert("ArrayProperty" == magic))]
|
|
|
|
Array(ArrayProperty),
|
2025-02-19 19:34:13 -05:00
|
|
|
#[br(pre_assert("MapProperty" == magic))]
|
|
|
|
Map(MapProperty),
|
2025-02-23 14:38:35 -05:00
|
|
|
#[br(pre_assert("SetProperty" == magic))]
|
|
|
|
Set(SetProperty),
|
2025-02-19 19:34:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Entry {
|
2025-02-23 16:00:35 -05:00
|
|
|
#[br(parse_with = read_string_with_length)]
|
2025-02-19 19:34:13 -05:00
|
|
|
#[bw(ignore)]
|
|
|
|
pub name: String,
|
2025-02-23 16:00:35 -05:00
|
|
|
|
|
|
|
#[br(parse_with = read_string_with_length)]
|
2025-02-19 19:34:13 -05:00
|
|
|
#[bw(ignore)]
|
2025-02-23 16:00:35 -05:00
|
|
|
#[br(temp, if(name != "None"))]
|
|
|
|
pub type_name: String,
|
|
|
|
|
|
|
|
#[br(if(name != "None"), args { magic: &type_name })]
|
2025-02-23 16:03:08 -05:00
|
|
|
pub r#type: Option<Property>,
|
2025-02-19 19:34:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct TaggedObject {
|
|
|
|
pub size_in_bytes: u32,
|
|
|
|
#[br(parse_with = until(|entry: &Entry| entry.name == "None"))]
|
|
|
|
pub entries: Vec<Entry>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct TaggedSerialization {
|
|
|
|
// Excluding the first four bytes, which is this
|
|
|
|
pub size_in_bytes: u32,
|
|
|
|
#[br(parse_with = until_eof)]
|
|
|
|
pub objs: Vec<TaggedObject>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct CompressedSaveFile {
|
|
|
|
pub magic: u64,
|
|
|
|
pub compressed_size: u64,
|
|
|
|
pub a_compresed_size: u64,
|
|
|
|
pub a_uncompresed_size: u64,
|
|
|
|
pub b_compresed_size: u64,
|
|
|
|
pub b_uncompresed_size: u64,
|
|
|
|
#[br(count = a_compresed_size)]
|
|
|
|
pub compressed_data: Vec<u8>,
|
|
|
|
}
|