diff --git a/paramacro/src/lib.rs b/paramacro/src/lib.rs index e6a9e91..d1be77b 100644 --- a/paramacro/src/lib.rs +++ b/paramacro/src/lib.rs @@ -54,8 +54,8 @@ pub fn serialized_struct(_metadata: TokenStream, input: TokenStream) // Add "None" field let none_field_stream = quote! { #[br(temp)] - #[bw(calc = crate::structs::PrimaryAssetNameProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )] - none_field: crate::structs::PrimaryAssetNameProperty + #[bw(calc = crate::structs::GenericProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )] + none_field: crate::structs::GenericProperty }; let buffer = ::syn::parse::Parser::parse2( syn::Field::parse_named, diff --git a/src/map_property.rs b/src/map_property.rs index 4ed90bc..cf319a6 100644 --- a/src/map_property.rs +++ b/src/map_property.rs @@ -3,16 +3,16 @@ use crate::common::{ }; use crate::guid::Guid; use crate::struct_property::{Struct, calc_size_in_bytes}; -use crate::structs::{PrimaryAssetNameProperty, PropertyBase}; +use crate::structs::{GenericProperty, PropertyBase}; use binrw::{BinRead, BinResult, binrw}; // parse until we can't parse no more. kind of a hack for how we run into the end of Persistent.Sav #[binrw::parser(reader, endian)] -fn cc() -> BinResult> { - let mut result = Vec::::new(); +fn cc() -> BinResult> { + let mut result = Vec::::new(); loop { - if let Ok(str) = PrimaryAssetNameProperty::read_options(reader, endian, ()) { + if let Ok(str) = GenericProperty::read_options(reader, endian, ()) { result.push(str); } else { break; @@ -25,7 +25,7 @@ fn cc() -> BinResult> { #[derive(Debug)] pub struct MapSubStructProperty { #[br(parse_with = cc)] - fields: Vec, + fields: Vec, } #[binrw] diff --git a/src/set_property.rs b/src/set_property.rs index 585c5fa..ddd3e06 100644 --- a/src/set_property.rs +++ b/src/set_property.rs @@ -1,16 +1,16 @@ use crate::common::{read_string_with_length, write_string_with_length}; use crate::map_property::{KeyType, MapSubStrProperty}; use crate::struct_property::Struct; -use crate::structs::PrimaryAssetNameProperty; +use crate::structs::GenericProperty; use binrw::{BinRead, BinResult, binrw}; // hack, we should be checking for "none" instead #[binrw::parser(reader, endian)] -fn cc() -> BinResult> { - let mut result = Vec::::new(); +fn cc() -> BinResult> { + let mut result = Vec::::new(); loop { - if let Ok(str) = PrimaryAssetNameProperty::read_options(reader, endian, ()) { + if let Ok(str) = GenericProperty::read_options(reader, endian, ()) { result.push(str); } else { break; @@ -27,7 +27,7 @@ pub enum SetValue { #[br(pre_assert("StructProperty" == magic && name != "OpenedStrongBoxIds" && name != "AcquiredItemBoxIds"))] Struct { #[br(parse_with = cc)] - fields: Vec, + fields: Vec, }, #[br(pre_assert("StringProperty" == magic || "NameProperty" == magic))] String(MapSubStrProperty), diff --git a/src/structs.rs b/src/structs.rs index fa8d029..e334dd3 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -45,10 +45,9 @@ pub struct SaveSlotInfoStruct { pub players: ArrayProperty, } -// TODO: replace all usage of this with StructField #[binrw] #[derive(Debug)] -pub struct PrimaryAssetNameProperty { +pub struct GenericProperty { #[br(parse_with = read_string_with_length)] #[bw(write_with = write_string_with_length)] pub property_name: String,