Replace fragile string parsing in structs
This commit is contained in:
parent
4eb1e7dd04
commit
5329fa08b2
1 changed files with 4 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
||||||
use crate::Property;
|
use crate::Property;
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
use crate::common::read_string_with_length;
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -28,43 +29,27 @@ pub struct DACharacterCommonStatusStruct {
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryAssetNameProperty {
|
pub struct PrimaryAssetNameProperty {
|
||||||
#[br(temp)]
|
#[br(parse_with = read_string_with_length)]
|
||||||
#[bw(ignore)]
|
#[bw(ignore)]
|
||||||
pub property_name_length: u32,
|
|
||||||
#[br(count = property_name_length)]
|
|
||||||
#[bw(map = |x : &String | x.as_bytes())]
|
|
||||||
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
|
|
||||||
pub property_name: String,
|
pub property_name: String,
|
||||||
|
|
||||||
#[br(temp)]
|
#[br(parse_with = read_string_with_length)]
|
||||||
#[bw(ignore)]
|
#[bw(ignore)]
|
||||||
#[br(if(property_name != "None"))]
|
|
||||||
pub type_length: u32,
|
|
||||||
#[br(count = type_length)]
|
|
||||||
#[bw(map = |x : &String | x.as_bytes())]
|
|
||||||
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
|
|
||||||
#[br(if(property_name != "None"))]
|
|
||||||
pub type_name: String,
|
pub type_name: String,
|
||||||
|
|
||||||
#[br(if(property_name != "None"))]
|
#[br(if(property_name != "None"))]
|
||||||
#[br(args { magic: &type_name})]
|
#[br(args { magic: &type_name})]
|
||||||
//
|
|
||||||
pub key: Option<Box<Property>>,
|
pub key: Option<Box<Property>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CarryCountProperty {
|
pub struct CarryCountProperty {
|
||||||
#[br(temp)]
|
#[br(parse_with = read_string_with_length)]
|
||||||
#[bw(ignore)]
|
#[bw(ignore)]
|
||||||
pub property_name_length: u32,
|
|
||||||
#[br(count = property_name_length)]
|
|
||||||
#[bw(map = |x : &String | x.as_bytes())]
|
|
||||||
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
|
|
||||||
pub property_name: String,
|
pub property_name: String,
|
||||||
|
|
||||||
#[br(args { magic: &property_name})]
|
#[br(args { magic: &property_name})]
|
||||||
//
|
|
||||||
pub key: Option<Box<Property>>,
|
pub key: Option<Box<Property>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue